I need to know how to clear session on Logout in MVC 4 asp.net
I have tried almost every thing but all in vain.
[AllowAnon
When you click on browser back button, it brings page from cache not from server. But user will not be able to perform any action on page displayed after back button.
If you still want page should not be displayed you should remove cache. It's a best practice. Here is the code. (Write in Global.asax.cs file)
protected void Application_BeginRequest()
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
}
After writing this code user will not see previous page after pressing back button.
The code written above to make Session object clear is right. No need to change any thing.