Using MVC2, I am attempting to show a user-friendly error message. Here is my approach:
public ActionResult Foo()
{
Response.StatusCode = 403;
return new ContentResult() { Content="friendly error" }
}
However, I am struggling to figure out how to access it in the AJAX OnFailure callback:
function ajaxErrorHandler(context) {
// This triggers an error, stating that it's not a JSON object
alert(context.get_response().get_object());
}
I can confirm through Firebug that the response is correct. Any suggestions?