How redirect to custom page after Session Timed out. There is error showing after session timedout :-
Directory Listing -- /
Thanks & Regards
Jagatpal Singh
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Apr 25, 2014, 12:52 AM EDT
Please use this in your page load event.
Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 3) + ";URL=~/Login.aspx"); Thankssudipta sanyalRank #1,945 · 753 reputationPosted Apr 25, 2014, 12:53 AM EDT
{
}
else
{
Response.Redirect("your_custom_page.aspx");
}
Chandradev PrasadRank #822 · 2.8K reputationPosted Apr 25, 2014, 2:12 AM EDT
http://vijaymeghwal.wordpress.com/2012/08/29/detecting-session-timeout-and-redirect-to-login-page-in-asp-net/
let me know, if your problem will not solve.
Chandradev PrasadRank #822 · 2.8K reputationPosted Apr 25, 2014, 2:43 AM EDT
Just Now i was testing your problem in my local i got one very simple way to fix your problem,
Step 1: Add this code in webconfig file like this. Note for testing i have kept 1 min
Step 2: You can keep this code in master page code behind like this
public int SessionLengthMinutes
{
get { return Session.Timeout; }
}
public string SessionExpireDestinationUrl
{
get { return "Home.aspx"; }
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.Page.Controls.Add(new LiteralControl(
String.Format("",
SessionLengthMinutes * 60, SessionExpireDestinationUrl)));
}
You can try this code in your application.