asp.net mvc 3 - Cannot receive JSON exception message/content type on remote requests -
i have asp.net mvc3 application, uses json comunicate flash ui.
i´m use actionfilterattribute handle json exceptions (from handle json exceptions gracefully in asp.net mvc 2: http://www.dotnetcurry.com/showarticle.aspx?id=496):
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; } } } it´s works ok when executes on localhost, details fiddler:
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 {"message":"no está autenticado"}
but, when executed remote clients, on lan example, response in "content-type: text/html" instead "content-type: application/json;" , content standard html error page:
500 - internal server error. there problem resource looking for, , cannot displayed.
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 what or need configure json response on remote requests?
i need flash ui receive http 500 error, json message instead html.
looking @ article javascript seems wire local requests. need using jsonp. (json padding). allow proper cross domain request returning json object.
Comments
Post a Comment