I want to sign out a user when his session times out. So used following code in Global.asax:
protected void Session_End(object sender, EventArgs e) { FormsAuthentication.SignOut(); }
But seems session_end never fires. Any idea how can fix it?
session_end
Session_end only fires in case of the Inproc session mode and not the Outproc session mode. In your web.config you need to have the sessionState element as a child of the element
<configuration> <system.web> <sessionState mode="InProc" timeout="2" /> ..... </system.web> </configuration>
Session_End is fired internally by the server, based on an internal timer. Because of that, there is no HttpRequest associated when that happens. That is why Response.Redirect or Server.Transfer does not make sense and will not work.
Session_End
HttpRequest
Response.Redirect
Server.Transfer
Remember the Session_End event will not fire in the case where the user closes the browser. HTTP is a stateless protocol. So there is no way for the server to understand that the browser has been closed.
© 2024 Digcode.com