在应用程序变量存储用户的细节 [英] Storing user details in application variable

查看:115
本文介绍了在应用程序变量存储用户的细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何存储大约100用户在应用程序变量的详细信息(用户名)?我知道如何使用会话,但我不知道如何使用应用程序变量以及如何在Global.asax文件存储?

How to store some 100 users details (username) in Application variable?I know how to use session but i dont know how to use Application variable and how to store in global.asax file?

推荐答案

应用程序的使用是绝对喜欢使用会话。但这个值是为所有用户共享的。

Using of Application is absolutely like using Session. But this value are shared for all users.

更新
在Global.asax中:

Update in 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;
}

这篇关于在应用程序变量存储用户的细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆