Make ajax get the main redirect page for login when autoload time

I am using ASP.Net MVC beta 1 and I am using the asp.net membership provider with a standard authentication controller to restrict access to my site.

I use the ajax function to provide, for example, editing values ​​by loading partial views into a div using jQuery $ .get / $. ajax or using the Ajax.Actionlink MVC helper. All this works great most of the time.

My problem occurs after the login time has expired, and you click on one of the ajax editing links - the ajax call returns the login page, which is placed in the div, usually used for the editing form.

I want to find a way to redirect the whole page to the login form when the authentication timeout and click on the ajax link.

One way that I can think of is to look at the html returned from the ajax call in the return response and look for the text field or the login input field and do the redirection from there - but this is not very clean - is there a better way?

+3
source share
1 answer

This may help some:

Workarounds Authentication is automatically redirected to login, how?

From the above answer, it looks like http 403 is not intercepted using forms authentication, so you can roll up your own ActionFilter, which returns an http 403 response if its request and Ajax authentication failed.

403 URL- .

, !

+2

All Articles