是静态的对象每个用户的独特之处? [英] Are static objects unique per user?

查看:94
本文介绍了是静态的对象每个用户的独特之处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET应用程序(C#)这是这样的

I have a .net application (c#) that goes something like this

public partial class _Default : System.Web.UI.Page
{
    #region initial variables setup

    private static exam theExam;

    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
       if(!IsPostBack)
       {
        string userid = Request.Querystring["user"].ToString();
           theExam = new exam(userid, "some values");
       }
    }
// rest of code.

现在我的问题是,如果创建并分配给顶部的静态申报考试theExam的实例用户105日志。如果用户204然后从不同的计算机登录,确实在顶部的静态对象获得的204甚至在价值用户的105的电脑?

Now my question is, if user 105 logs in an instance of exam theExam is created and assign to the static declaration on top. If user 204 then logs in from a different computer, does the static object at the top gets the value of 204 even on user's 105's computer?

推荐答案

没有,静态对象是同一个实例为大家登录。另外,对象不活105的计算机上,但只是在Web服务器上ofcourse

No, the static object is the same instance for everyone logged on. Also the object doesn't live on 105's computer but just on the web server ofcourse.

这篇关于是静态的对象每个用户的独特之处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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