The model and controllers in my MVC application throw LoginRequired exceptions whenever a public user attempts to access a secure resource. I am listening for dispatch errors and when I detect one that is a LoginRequired exception, I then construct and return a custom response.
If the request was a normal HTTP request things are simple - I return a 302 redirect, and the 'location' is the login page. But what about when the request is AJAX?
I have read here How to manage a redirect request after a jQuery Ajax call about setting a response header then looking for it in a global ajax success handler. I can do that no problems, but surely there should be a HTTP status code to deal with this?
What would be a good choice of code? I need one that is a reasonably good fit semantically, but is not going to automatically invoke any behaviour on the user agent.