Logout from MVC
-
Hi, I have a MVC application and I have to logout. To logout from the application I have created a link on te master page
[ <a id="A2" name="lnkLogout" href="http://localhost:1234/Home/LogOut" >Logout</a> ]
and created the LoutOut action in the controller page
public ActionResult LogOut()
{
Session.Clear();
Session.Abandon();
Redirect("http://AnotherApplicaton/Home/LogOut");
}Now when I click on the LogOut link its redirect to the LogOut action and in the LogOut action its delete all the session, but when I click on the back button of the browser its get back to the previous page and sessions are still alive. Does anyone have the solution of this problem.
Pankaj
-
Hi, I have a MVC application and I have to logout. To logout from the application I have created a link on te master page
[ <a id="A2" name="lnkLogout" href="http://localhost:1234/Home/LogOut" >Logout</a> ]
and created the LoutOut action in the controller page
public ActionResult LogOut()
{
Session.Clear();
Session.Abandon();
Redirect("http://AnotherApplicaton/Home/LogOut");
}Now when I click on the LogOut link its redirect to the LogOut action and in the LogOut action its delete all the session, but when I click on the back button of the browser its get back to the previous page and sessions are still alive. Does anyone have the solution of this problem.
Pankaj
hi <script type="text/javascript" language="javascript"> javascript: window.history.forward(1); </script>
-
Hi, I have a MVC application and I have to logout. To logout from the application I have created a link on te master page
[ <a id="A2" name="lnkLogout" href="http://localhost:1234/Home/LogOut" >Logout</a> ]
and created the LoutOut action in the controller page
public ActionResult LogOut()
{
Session.Clear();
Session.Abandon();
Redirect("http://AnotherApplicaton/Home/LogOut");
}Now when I click on the LogOut link its redirect to the LogOut action and in the LogOut action its delete all the session, but when I click on the back button of the browser its get back to the previous page and sessions are still alive. Does anyone have the solution of this problem.
Pankaj
No need to think about the browser back button... If there is no session, every request that is made from the client in the cached page will generate errors. :) Also if possible place history.go(1); in the masterpage or every page. So that whenever the back button is clicked, it will automatically forward to the latest page. ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript -
No need to think about the browser back button... If there is no session, every request that is made from the client in the cached page will generate errors. :) Also if possible place history.go(1); in the masterpage or every page. So that whenever the back button is clicked, it will automatically forward to the latest page. ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using JavascriptThanks for you replay. Back button is not my problem. The problem is sessions are not expiring. When I go back to previous page and refresh the browser, I get all the information from the database again, this should not happen. Because before every database request its checks whether session is exist or not. If session is not exists then no database call will be fired. But this is not happening after the logout.
Pankaj
-
Thanks for you replay. Back button is not my problem. The problem is sessions are not expiring. When I go back to previous page and refresh the browser, I get all the information from the database again, this should not happen. Because before every database request its checks whether session is exist or not. If session is not exists then no database call will be fired. But this is not happening after the logout.
Pankaj
I think it is better to check a
Session
value on every call to the server. Like :try{
if(Convert.ToBoolean(Session["IsAuthenticated"]) != true)
Server.Transfer("loginpage.aspx");
}
catch{
Server.Transfer("loginpage.aspx");
}During Login put this Session Value and In Logout clear out this value. :)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript