开发者

Custom JSONP error handling showing generic “Error Occurred” page to remote users only

开发者 https://www.devze.com 2023-03-31 08:38 出处:网络
I’m using an ExceptionFilter to set the response code to 500 and show a JSONP representation of the exception:

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消