How to redirect to login page automatically, after session time out.

.NET Programming Question

How to redirect to login page automatically, after session time out?
In my web application, user logs in in the application, after a certain time (30 mins) session times out and login page appears only AFTER user action.
I would like to redirect the user back to the login screen automatically (before user performs any action) after session has timed out.

Your suggestions will be greatly appreciated.

I used following code in pagerender of masterpage.
 HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString(((HttpContext.Current.Session.Timeout * 60) - 5)) + "; Url=homepage.aspx")
Also, i have Session_Start/Session_end in global.asax.


Select allOpen in new window

Default Text

Verified Answer?

The member who asked this question verified this comment provided the solution that solved their problem.

by:Posted on 2008-05-14 at 05:49:36ID: 21563505

function timeout(){window.location = ""}

call it in your html:
<body onload="setTimeout('timeout()', 5000)">

But you would still have to put this into every page... not sure how you are going to accomplish this without masterpages.

This content is available to Experts Exchange members

See the answer now
with your Free 30 Day Trial

Get unlimited access to solutions & experts

  • 4,169,477 solved questions
  • 3,805 articles & videos
  • 15,413 tech experts

Get Access Now

Need a customized answer?
Ask your question for one-on-one assistance. We will email you when an expert has commented on your question.

We will never share this with anyone. Privacy Policy Terms of Use

Select topics

You may select up to five topics.


Related Articles

Related Questions