Custom JSONP error handling showing generic “Error Occurred” page to remote users only
I’m using an ExceptionFilter
to set the response code to 500
and show a JSONP representation of the exception:
filterContext.ExceptionHandled = true;
filterContext.HttpContext.Response.StatusCode = 500;
filterContext.Controller.ViewBag.callback = GetCallBack(filterContext);
filterContext.Result = new ViewResult
{
ViewName = GetFormat(filterContext),
ViewData = new ViewDataDictionary(new [] { new { message = "sorry!" } }),
TempData = filterContext.Controller开发者_StackOverflow社区.TempData
};
This is working fine locally, displaying:
whatever([{ "message": "sorry!" }]);
when called locally.
However, when called from a remote machine, I get the IIS7 generic “Error Occurred” page. How can I get my custom content to display instead?
精彩评论