2012-08-09 185 views

回答

1

应用程序的使用与使用Session完全相同。但是这个值是所有用户共享的。

更新 在Global.asax中:

void Application_Start(object sender, EventArgs e) 
{ 
    var userList = new List<string>(); 
    Application["UserList"] = userList; 
} 
void Session_Start(object sender, EventArgs e) 
{ 
    var userName = Membership.GetUser().UserName; 

    List<string> userList; 
    if(Application["UserList"]!=null) 
    { 
     userList = (List<string>)Application["UserList"]; 
    } 
    else 
     userList = new List<string>(); 
    userList.Add(userName); 
    Application["UserList"] = userList; 
} 
+0

但是我可以在哪里存储用户的详细信息?在global.asax文件中?如何知道当前登录哪个用户? – 2012-08-09 17:22:08

+0

我更新了答案 – 2012-08-09 17:47:34

2
var users = new List<string>(){ 
    "mary", "bob" 
}; 
HttpContext.Current.Application["users"] = users; 
+0

我可以存储详细信息在Global.asax文件在全球范围内使用的细节? – 2012-08-09 17:20:17

+0

@Chandrasekhar是 – xandercoded 2012-08-09 17:21:17

+0

如何知道当前登录的用户?我们如何检索用户详细信息? – 2012-08-09 17:35:16

相关问题