how to save value in prperties in place of session?
I an using Session for storing UserName for whole project. But it always time out before 20 min. I want set v开发者_JS百科alue in properties and want to use in project but when my page is loading again its showing null value.
How can i save this value in this?
Code what i am using.
public string UserName {get; set; }
public string Password {get; set;}
Properties are a language construct (not an ASP.NET feature) and won't survive either.
You should persist the information in a database or up the session timeout.
With a public string UserName {get; set;}
you don't set anything in the Session.
Use this instead:
public string UserName
{
get { return Session["UserName"] as string; }
set { Session["UserName"] = value; }
}
精彩评论