About the author

Vijay Kodali
E-mail me Send mail

Site Statistics

Site Meter

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Detecting Session Timeout and Redirect to Login Page in ASP.NET

HTTP(web page) is stateless, so we cannot know whether the Session has really expired without sending a page request back to the server. If you want to redirect the page immediately(with out any user action) after session expires consider this approach.

 

Response.AppendHeader("Refresh",Convert.ToString((Session.Timeout * 60)+ 10)+";URL=Login.aspx");

 

Add this line of code to page_Load.


Tags:
Categories: ASP.NET | ASP.Net 3.5
Posted by vijay on Friday, April 11, 2008 6:35 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Comments

Suraj United States

Thursday, April 30, 2009 11:35 AM

Suraj

I found this code, which consists -5. Actually what is that number means and its sign?

HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString(((HttpContext.Current.Session.Timeout * 60) - 5)) + "; Url=YOUR PAGE WHICH YOU WANT TO SHOW");

Tinitus United States

Wednesday, September 01, 2010 9:08 PM

Tinitus

I've had tinnitus ever since I was twelve.  Until recently though I did not know that itwas such a large problem with thousands of people until I saw somewhere that Jessica Simpson suffered from tinnitus.  I'm happy that I discovered help and products that can actually cure my tinnitus.  Thank you so much for the info!

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading