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.
>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.