when I build asp.net applications that require user login, I write a method in my businees class that returns a Member object instance if the user is logged in, null if not. Then I do this:
Session["User"] = user;
Then in every page load I have to implement this:
User user = Session["User"] as User;
if(null==user){
//toggle the state of ascx, to show username/password boxes again,
//Response.Redirect("somewhere else") etc...
}
This looks like its working, but is this a good approach? Because sometimes the Session does not return that object anymore. It happens before 20mins, which is default timeout for session. Is there any reson for that? It happens randomly, when I make several postbacks during testing.
Thanks in advance.