开发者

Static variables in IIS-hosted web applications

If I declare a static field in a type 开发者_运维问答instantiated within an ASP.NET application, hosted within IIS, is the same variable (i.e. same memory location) used by all of the worker threads used by IIS, opening up concurrency issues?


Yes. Static variables are shared across an entire AppDomain, which means all worker threads that live in that AppDomain share the same "instance" of that variable.

Static variables are generally a poor choice for highly concurrent applications, like web apps. Depending on your specific scenario, consider session variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜