Click here to Skip to main content
15,908,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have to redirect to a page when the session gets expired. I need to write the code in Global.asax. At which event I have to write the code which get triggered when the page expired. Kindly help me.

Thanks,
Janes
Posted

In global.asax in the Session_Start event. You can check for a session cookie in the request there. If the session cookie exists, the session has expired:
C#
public void Session_OnStart()
       {
           if (HttpContext.Current.Request.Cookies.Contains("ASP.NET_SessionId") != null)
           {
               HttpContext.Current.Response.Redirect("SessionTimeout.aspx")
           }

       }
 
Share this answer
 
See the quite similar question which you asked. I already answered that.
Page redirect during Session Timeout[^]


--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900