Link to home
Start Free TrialLog in
Avatar of resourcesys
resourcesys

asked on

Alternative to Response.Redirect on session end

Hi all,

I have the following code in a global.asax file:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    Response.Redirect("~/Relogin.htm")
End Sub


The problem is that when the session ends, the Response object seems to be null and so I am getting an error.

Does anyone have an alternative to this or is it possible to create a new response object.

Thanks.

resourcesys.
Avatar of Pratima
Pratima
Flag of India image

Session_End is fired internally by the server, based on an internal timer. Thus, there is no HttpRequest associted when that happens. That is why Response.Redirect or Server.Transferdoes not make sense and will not work.
Use forms authentication

<authentication mode="Forms">
        <forms name=".Login" loginUrl="LoginPage.aspx"
            protection="All" path="/" timeout="5" />
    </authentication>
.....

<sessionState mode="InProc" ... timeout="5"/>

this way whenever the session expires the form authentication too times out and when the user clicks on anything he will be redirected to login page..
Avatar of resourcesys
resourcesys

ASKER

Cannot use forms authentication.

Has to be from within the session end method.
ASKER CERTIFIED SOLUTION
Avatar of resourcesys
resourcesys

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No acceptable solution provided