Click to See Complete Forum and Search --> : session_end and re-login


buranfb
July 10th, 2003, 04:19 AM
Dear ASP.NET Programmers,

I am using forms authentication in my web application. I would like the users to be transferred to the login page when the session expires. I am using session state, but the following code in global.asax file does not work:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
FormsAuthentication.SignOut()
Response.Redirect("login.aspx")
End Sub

How can I solve this problem or work around it?

buranfb

coolbiz
July 10th, 2003, 07:13 AM
RESPONSE object is not available for you during that event. To detect if a user needs to login, use the SESSION_START event. There most common way to do it is to set a SESSION variable as a flag whether the user has logged in or not.

So during SESSION_START, you can check for this variable. If it is there and the flag is set, then the user has already logged in. Otherwise you can redirect to the login form.

The variable flag should be set by the login form upon successful logon.

-Cool Bizs