Geeks With Blogs
Amit's Blog Sharing Thoughts and Learning

While visiting Asp.net forum I found a lot of request on how to show a different page when the asp.net session expires. The following line will exactly do the same:

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

It simply injects a meta data which refresh the pages in the client side. If you are using any master page you can add this line in the PreRender event

kick it on DotNetKicks.com

Posted on Saturday, June 9, 2007 12:58 AM Asp.net , Tips/Tricks | Back to top


Comments on this post: Redirects to a different page when Asp.net session expires

# Show a Page when Asp.net session expires
Requesting Gravatar...
You've been kicked (a good thing) - Trackback from DotNetKicks.com
Left by DotNetKicks.com on Jun 09, 2007 1:07 AM

# Links (6/10/2007)
Requesting Gravatar...
.NET IEnumerable and Yield in .NET 2.0 PowerShell: Defining Guids Being Ignorant with LINQ to SQL - in
Left by Member Blogs on Jun 11, 2007 7:25 AM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
nice tip!... it solves a problem here

keep up the great job

thanks
Left by Osvaldo Pontes on Jun 19, 2007 7:21 AM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
Great!!
I've been looking for something like this for so long...
Keep posting to your blog. It is one of the best ASP.NET Ajax I've seen.
Left by Shahar Nechmad on Jul 11, 2007 10:26 PM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
Thanks for your inspiring comment.
Left by Kazi Manzur Rashid on Jul 11, 2007 11:24 PM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
choukrane (thank you in)
this solved a great problem for me
Left by EL FIGHA on Oct 10, 2007 6:15 PM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
Wow... thanks a bunch for a great tip. It works for me :-)
Left by Nuk Chitchulaon on Nov 13, 2007 2:26 AM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
Hello,
I could not understand this code; can someone guide me where to put this code and how it works. I need to add it on every page or in Global file. I want to add same feature in my ASP.Net (VB.Net) web application. Thanks in advance
Left by Kayani on Jan 02, 2008 10:35 PM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
Excellent code exactly what I am looking

Kayani Add this code in the load event of your form just
Left by shani on Aug 03, 2008 7:14 AM

# re: Redirects to a different page when Asp.net session expires
Requesting Gravatar...
great Solution.. u slove my half solution.
Left by kaz on Sep 17, 2008 12:29 PM

Your comment:
 (will show your gravatar)
 


Copyright © Kazi Manzur Rashid | Powered by: GeeksWithBlogs.net | Join free