In my ASP.NET MVC4 application, I'm using forms authentication. One view in the app needs to get some string data via a jQuery post()
call. I wrote an action that returns string. Everything works fine until the forms authentication ticket expires. After expiration, the AJAX call to the string action results in following:
- The code within the action does not get executed
- The action returns a HTTP 200 and not a 401
- The action returns HTML of the Login view as string
- Because 200 status was returned and not 401, the control ends up in
jqXHR.done()
instead ofjqXHR.fail()
Is this expected behavior? Can I do something to make the action return a 401? Or is there something else I should be doing to handle this?