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"
protected void Session_End(Object sender, EventArgs e){
Request.Cookies["GOAM_REPORTS_COOKIE"].Expires = DateTime.Now.AddYears(-10);
}
try{
oUserId.Value = (int)Session["iid"];
}
catch{
Shared.HandleLostSession();
}
public static void HandleLostSession(){
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.