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 Problem

Status
Not open for further replies.

jbtman

Programmer
Jul 13, 2007
30
I have web appliation done that uses master pages. I have two content pages, Default and Account. When the application loads Default loads and allows the user to log in. This sets a session variable this way

HttpContext.Current.Session.Add("UserValidated", True)

and then redirects to the Account page

There is a logout button on the account page that does this

HttpContext.Current.Session.Item("UserValidated") = "False"
HttpContext.Current.Session.Abandon()
HttpContext.Current.Session.Clear()
Response.Redirect("Default.aspx")

I have a session checking function in place in the page events of the master page.

Now if I try to go to the Accounts page directly without logging in it succeeds as the Session checking function does not get called.

In the master page I have tried putting the session check function in the page load, init, preinit and everywhere else I can think of!!

Any help would be appreciated!!
 
Oh, when I say go to the Account page directly I mean after I have logged out and got sent to Default.
 
I have tried that as well. It is currently in the page load of the master page, which does not get executed, and neither does the page load event of the Accounts page.

Here is the function

Public Function CheckSession() As Boolean
Dim blnSessionValid As Boolean

blnSessionValid = HttpContext.Current.Session.Item("UserValidated")
If Not blnSessionValid Then
Return False
Else
Return True
End If
End Function
 
Update:

If I put this into the Page_Load event of my master page it seems to work find.

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ExpiresAbsolute = DateTime.Now.AddMonths(-1)

Could that code be problematic?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top