c# - Global jQuery AJAX error handling with MVC 3 unobtrusive Javascript -


i have global error handler ajax calls looks this:

$.ajaxsetup( {     error: function(xmlhttprequest, textstatus, errorthrown)     {         alert("error");     } }); 

and i'm making ajax call this:

@ajax.actionlink("submit", "submitquery", new ajaxoptions { httpmethod = "post" }) 

on controller action have customauthorizeattribute returns:

filtercontext.result = new httpstatuscoderesult(403, "adsfasd"); 

when user isn't logged in.

for reason global jquery ajax error handler isn't catching 403 error.

i managed figure out.

i needed:

filtercontext.result = new contentresult {     contenttype = "text/plain",     content = "access denied. invalid user name and/or password." };  filtercontext.httpcontext.response.status = "500 ".replace("\r", " ").replace("\n", " "); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -