javascriptc#asp.netsessionend

Codes to be inserted to Session_End block to notify user timeout or redirect


How to display a popup window in C# that tell the user the session has expired? I am thinking about an analogy in JavaScript alert "Your session has expired";. Is there such analogy in C#?

Alternative solution is to direct my user to Default.aspx page. I have seen many lines of code using Google, but none of them work in protected void Session_End(object sender, EventArgs e) {} block. I am looking for lines of code that can be inserted into Session_End block. Otherwise, I would have to insert the codes into over 200 .aspx pages.

I also know that HTTP is stateless and Response.Redirect() doesn't work when the Session_End() fires.


Solution

  • Simply stated, if it reached Session_End it's too late to notify the client. At that point, everything is gone.

    You mention modifying 200 pages, but if you're using a Master Page (which I hope you would be), that would be the most elegant place to put a timeout warning.