公共变量和应用变量 [英] Public vars and Application vars

查看:90
本文介绍了公共变量和应用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计!

今天,使用我的新第一个代码asp.net进行了神秘的体验

我在模块中使用了声明"public var",并且从所有用户(如var application)中查看了这些内容!

是正确的?
为什么会这样?
是否可以仅在需要运行应用程序var的情况下使用我的应用程序var,而仅在运行应用程序的用户的套接字http中使用我的公共变量?

tks,
最好的问候

解决方案

您正在将应用程序实例与会话实例混淆. 每次用户访问您的Web应用程序时,都会为他们创建一个新的会话,因此模块或类(无论如何)中的所有公共变量都不会与其他用户共享,直到您将其标记为STATIC


Hi guy!

Today have make a mystic experience with my new first code asp.net

I use declare "public var" in my module and thats are viewed form ALL users like var application!!

Is right?
Why this?
Can I use application var only if I want do it and my public variable in my application only for the socket http of the user that run application split by user?

tks,
best regards

解决方案

you are confusing application instance with session instance..
everytime a user accesses your web application, a new session is created for them, so all public variables in your module or class (whatever) are not shared with other users UNTIL you mark them as STATIC


这篇关于公共变量和应用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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