ASP.NET C# Static Variables are global?

后端 未结 4 1516
执念已碎
执念已碎 2020-11-29 07:00

Today I released a small asp.net beta web application which allows internal staff to modify some product information. We started running into issues where users were overwri

4条回答
  •  囚心锁ツ
    2020-11-29 07:20

    It's incorrect to say that a static variable exists application wide. They in fact exist at two different levels

    1. For non-generic types there is a single static variable per AppDomain
    2. For generic types there is one per generic instantiation per AppDomain

    An application can contain many AppDomains and is true in several types of applications.

    If you want to store user specific settings though, use a Session variable.

提交回复
热议问题