开发者

how to save value in prperties in place of session?

开发者 https://www.devze.com 2022-12-19 06:16 出处:网络
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 agai

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; }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消