2012-08-09 105 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

相關問題