Last post Jun 13, 2018 08:28 AM by Yohann Lu
Jun 12, 2018 09:30 AMemail@example.com|LINK
Could anyone help me in resolving my problem with Global.ascx file ?
I have to redirect to CompanyLoginForm.aspx automatically when Session is Timed out. I have changed Session Timeout to "1" so that session will be timed out in 1 minute.
Below is the code used :
Below is the code used in Global.ascx file:
void Session_Start(object sender,
// No Code
void Session_End(object sender,
void Application_Error(object sender,
// Code that runs when an unhandled error occurs
HttpContext context =
Exception ex = context.Server.GetLastError();
//process your exception
catch (Exception ex)
Could any one suggest me in fixing the issue, when time is out application is not redirecting to
CompanyLoginForm.aspx, instead it is showing the page which we opened earlier.
Could you any body share the sample code, you have come across the same scenario ?
Jun 12, 2018 09:57 AM|mgebhard|LINK
Your approach will not work because there is no context or response object to redirect. The Session_End event clears user data from Session disconnected from the user. Otherwise the application will run out of memory as more user use the system and store
data in Session. The web server does not have a connection to the individual clients.
I suggest that you use established patterns and practices rather than Session for storing user authentication. ASP.NET comes with authentication/authorization APIs that handle the redirect automatically. The user is redirected if the request is not authenticated.
Jun 13, 2018 08:28 AM|Yohann Lu|LINK
The following samples introduce another way to automatically redirect to the Login page When Session is timed out.
Automatically redirect User after Session Timeout in ASP.Net