ASP.NET环境中的共享变量 [英] Shared variables in ASP.NET environment
问题描述
IIS上的ASP.NET体系结构的结果刚刚回归到了家里,并且带来了很大的价值。它与共享变量有关。考虑这样一个模块:
公共模块函数
Public GlobalName As String''这对全局无效
应用程序对象
结束模块
由于所有用户共享一个aspnet_wp.exe进程,所有用户都会
访问相同的GlobalName变量。因此,如果用户A运行应用程序并且
将其设置为Fred。并且用户B将其设置为Bert,然后用户A看到新的
值?
这是正确的吗?
>
干杯,Rob。
A consequence of the ASP.NET architecture on IIS has just hit home with a
big thud. It''s to do with shared variables. Consider a module like this:
Public Module Functions
Public GlobalName As String '' this is ineffect a global
application object
End Module
As there is one aspnet_wp.exe process shared by all users, would all users
access the same GlobalName variable. So if user A runs the application and
sets it to "Fred" and user B sets it to "Bert", then User A sees the new
value?
This this right?
Cheers, Rob.
推荐答案
>由于所有用户共享一个aspnet_wp.exe进程,所有用户
> As there is one aspnet_wp.exe process shared by all users, would all users
都将访问相同的GlobalName变量。因此,如果用户A运行应用程序并将其设置为Fred,则将其设置为Fred。并且用户B将其设置为Bert,然后用户A看到新的
值?
access the same GlobalName variable. So if user A runs the application and
sets it to "Fred" and user B sets it to "Bert", then User A sees the new
value?
回答我自己的问题,但是,这就是发生的事情。所有用户访问
相同的共享变量......
干杯,Rob。
Answering my own question but yes, this is what happens. All users access
the same shared variables...
Cheers, Rob.
您好,
将它存储在会话状态。
会话(" GlobalName")=" Rob Nicholson"
http://msdn.microsoft.com/library/de...ssionstate.asp
Ken
----- -------------
Rob Nicholson <在****** @ community.nospam>在消息中写道
news:et ************** @ TK2MSFTNGP10.phx.gbl ...
Hi,
Store it in session state.
Session("GlobalName")="Rob Nicholson"
http://msdn.microsoft.com/library/de...ssionstate.asp
Ken
------------------
"Rob Nicholson" <in******@community.nospam> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
ASP的结果IIS上的.NET体系结构刚刚回归大家。它与共享变量有关。考虑这样一个模块:
公共模块功能
Public GlobalName As String''这对一个全局的
应用程序对象无效
结束模块
由于所有用户共享一个aspnet_wp.exe进程,所有用户都将访问相同的GlobalName变量。因此,如果用户A运行应用程序并将其设置为Fred,则将其设置为Fred。并且用户B将其设置为Bert,然后用户A看到新的
值?
这是对的吗?
干杯,Rob。
A consequence of the ASP.NET architecture on IIS has just hit home with a
big thud. It''s to do with shared variables. Consider a module like this:
Public Module Functions
Public GlobalName As String '' this is ineffect a global
application object
End Module
As there is one aspnet_wp.exe process shared by all users, would all users
access the same GlobalName variable. So if user A runs the application and
sets it to "Fred" and user B sets it to "Bert", then User A sees the new
value?
This this right?
Cheers, Rob.
>会话(GlobalName)=Rob Nicholson
嗨肯 - 我想到了但问题是这个变量是
需要深在一个中间层,我没想到,关于
当前会话的新内容。然而,我随后发现:
System.Web.HttpContext.Current.Session(" GlobalName")
这意味着中间tier可以在会话缓存中获取,而不必将
传递给指向它的指针。
我假设System.Web.HttpContext.Current实际上是一个共享(静态)
属性'可用进程范围并返回HttpContext对象
用于当前正在处理的请求,这反过来又为用户提供了'自己的
会话状态。
干杯,Rob。
> Session("GlobalName")="Rob Nicholson"
Hi Ken - I thought about that but the problem was that the variable was
needed deep in a middle tier layer which, I didn''t think, new about the
current session. However, I then found:
System.Web.HttpContext.Current.Session("GlobalName ")
which means the middle tier can get at the session cache without having to
pass a pointer to it all over the place.
I assume that System.Web.HttpContext.Current is in effect a shared (static)
property that''s available process wide and returns the HttpContext object
for the current request being processed which in turn gives the user''s own
session state.
Cheers, Rob.
这篇关于ASP.NET环境中的共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!