I am developing an ASP.NET 3.5 WebForms application where I want a session to time out after a certain period of time. After which, if the user is trying to do something, the application should redirect them to a page that indicates that the session is completed and that they will need to start all over again. As far as I know, as far as I know.
However, I cannot get the session timeout to test this functionality, either from within Visual Studio or from IIS. Here are my session state settings in web.config:
<sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="<ConnectionString>" cookieless="false" timeout="1" />
This is how I test the session timeout:
public bool IsSessionTimeout { get { // If the session says its a new session, but a cookie exists, then the session has timed out. if (Context.Session != null && Session.IsNewSession) { string cookie = Request.Headers["Cookie"]; return !string.IsNullOrEmpty(cookie) && cookie.IndexOf("ASP.NET_SessionId") >= 0; } else { return false; } } }
It seems that Session.IsNewSession always returns false , which makes sense because the Session_End method is never called in my Global.asax.cs. What am I missing?
source share