i am developing a website in asp.net
i have created a class "Utility" in App_Code Folder
this class contains a static object of another class(LoginInfo) as described below:
public class Utility
public static LoginInfo CurrentUser = new LoginInfo();
This LoginInfo Class is my business object which only contains 2 properties UserID and UserName
Now what i am doing on my login page, after user authentication i am setting these properties with current logged in UserId and UserName
protected void Login_Click(object sender, EventArgs e)
if (Authenticated User)
Utility.CurrentUser.UserID = "001"; //ID of current logged in user
Utility.CurrentUser.UserName = "Admin" //Username of current logged in user;
I am using this CurrentUser object on my webpage to get userid and username.
It works fine, but after few minutes my CurrentUser.UserID and CurrentUser.UserName is set to blank string.
I am not able to figure out what is the problem. may be due to asp.net recycles.
Please help me how should i solve this problem? Is there any other way?
View Complete Post