Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot receive JSON exception message/content type on remote requests
    primarykey
    data
    text
    <p>I have a ASP.NET MVC3 application, which uses JSON to comunicate with a Flash UI.</p> <p>I´m use an ActionFilterAttribute to handle JSON exceptions (from Handle JSON Exceptions Gracefully in ASP.NET MVC 2: <a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=496" rel="nofollow">http://www.dotnetcurry.com/ShowArticle.aspx?ID=496</a>):</p> <pre><code> public class HandleJsonExceptionAttribute : ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.Exception != null) { filterContext.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; filterContext.Result = new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { filterContext.Exception.Message, } }; filterContext.ExceptionHandled = true; } } } </code></pre> <p>It´s works ok when executes on localhost, details from fiddler:</p> <p><pre><code> HTTP/1.1 500 Internal Server Error Cache-Control: private Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNetMvc-Version: 3.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 11 Apr 2011 19:05:21 GMT Content-Length: 34</p> <p>{"Message":"No está autenticado"} </pre></code></p> <p>But, when executed from remote clients, on the LAN for example, I get the response in "Content-Type: text/html" instead "Content-Type: application/json;" and the content is a standard html error page:</p> <p>500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.</p> <p><pre><code> HTTP/1.1 500 Internal Server Error Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNetMvc-Version: 3.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 11 Apr 2011 19:07:53 GMT Content-Length: 1208 </pre></code></p> <p>What or where I need to configure something to get the JSON response on remote requests?</p> <p>I need the flash UI receive a http 500 error, but with the json message instead the html.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload