Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page_Load not firing session timeout

Status
Not open for further replies.

WIREMESH

Programmer
Mar 15, 2004
109
US
Sub Page_Load()

>When session timeout occurs, I want to navigate to a login page. I have seen several code examples such as below:

If Http.Current.Session("USER_ID") Is Nothing
Http.Current.Response.Redirect("LOGINPAGE.ASPX")
End if
End Sub


my problem is, when the session times out, the page_load method is not being called.To test, in the Page_Load of my test form include the code above with a test for a text file I create with windows notepad.
>Ex.


Sub Page_Load()
if HttpContext.Current.Session("USER_ID") Is Nothing
HttpContext.Current.Response.Redirect("LOGIN.ASPX")
End If

filename = Request.PhysicalApplicationPath() + "ZZZ.TXT"
If IO.File.Exists(filename)
IO.File.Delete(filename)
HttpContext.Current.Response.Redirect("LOGIN.ASPX")
End If
End Sub



When I create the text file, when I click on a button on the page, the form properly navigates to the login page, deleting the text file. When the timeout occurs and the text file exists, the text file is not deleted, letting me know the page_load was not run.
I also simulate this by modifying my web.config file. When I modify this code, the page_load again is not run, and I get an error on my page when any session variable is accessed.
 
that code should be put in the Session_End event of the Global.asax. However, that is not guaranteed to work either.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top