i have created a MVC application , without using asp.net membership provider, i want to redirect the user to the login page if the user logged out and press back button from explorer.
Thanks
i have created a MVC application , without using asp.net membership provider, i want to redirect the user to the login page if the user logged out and press back button from explorer.
Thanks
You can't do this, as the page the user see when clicking 'back' is in fact the cached version of the page.
The best you can do is request the browser to not cache logged in pages, to do this you would place:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
on all pages you consider shouldn't be 'back button' accessible.
This is only a request however, browsers are under no obligation to oblige.
Now i can think in two solutions, you could create a filter for your controller, and control to authentication by Session, Cookies, etc... (what I don't recommend)
Sample of Actions Filters http://www.asp.net/mvc/tutorials/understanding-action-filters-cs
Second one and the best in my opinion, I preffer to do something more simple for Authentication, like Forms Authentication... take a look at this link:
I use this approach in my projects and works fine! Simple and easy! I don't like very much of Membership provider.
I hope it help you!
PS: sorry for my english!