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("~/Relog in.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.
I have the following code in a global.asax file:
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("~/Relog
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.
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..
<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..
Refer this article http://weblogs.asp.net/bleroy/archive/2004/08/03/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_.aspx
it might be useful
it might be useful
Refer this link http://geekswithblogs.net/shahed/archive/2007/09/05/115173.aspx definitely helps you
ASKER
Cannot use forms authentication.
Has to be from within the session end method.
Has to be from within the session end method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No acceptable solution provided