Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Session timeout
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00654837
Message ID:
00654895
Views:
17
Hi,

We learned it the hard way <g>. Redirecting to another page from Session_End attempts to access the session.

The Session_End event is triggered when a session ends, either by closing all the browser windows for the session or when Session.Abandon() is called. This is generally the last point for cleanup allowing you to forcefully expire cookies if you have any.

We are using forms based authentication and this is how we tell our users "Your session is now expired and you need to sign-in again"
//1. Global.asax
protected void Session_End(Object sender, EventArgs e){
	//Expire the cookie on the client when the user exists the application
	Request.Cookies["GOAM_REPORTS_COOKIE"].Expires = DateTime.Now.AddYears(-10);
}

//2. In our base page class Load() event, we simply try and access 
//   the session and call HandleLostSession() if an exception occurs
try{
	oUserId.Value = (int)Session["iid"];
}
catch{
	Shared.HandleLostSession();
}

//3. Lost Session handing through static method
public static void HandleLostSession(){
	//Wrapper for redirecting user to the logon page back on a session error
	System.Web.HttpContext.Current.Response.Redirect("SessionError.aspx");
	System.Web.HttpContext.Current.Response.End();
}
Not the cleanest of approaches but this is the best we could come up with when .NET was still in beta. Hope there is something better today.

Kamal

>Session Timeout Redirect
>angelica saldivar - 5/9/2002 8:03:54 PM
>
>--------------------------------------------------------------------------------
> I am trying to figure out how to redirect a user to a default 'session timed out' page when session times out.
>I have added the following in the global.asax file :
>
> Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
> Response.Redirect("sessionstate.asp")
> End Sub
>
>Nothing happens when session times out, screen comes up with errors--my pages trying to use session variables that have expired.
>
>Is there a way to redirect user automatically to this page when session ends? I thought the session_end event would be called.
>
>Anyone know what I am missing?
>
>Thanks in advance.
>Angelica.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform