简体   繁体   English

具有2个实例的IIS ASP.NET应用程序中的静态变量

[英]Static Variable in IIS ASP.NET application with 2 instances

I have a single code folder, c:\\some-ASPNETMVC-site 我有一个代码文件夹, c:\\ some-ASPNETMVC-site

That folder is pointed to by 2 IIS7 Sites , each site has its own application pool . 该文件夹由2个IIS7站点指向,每个站点都有自己的应用程序池

If I set a static variable, in this case a log4net appender's log file path, at run time to a value different in each site, will the values over write each other, or will it be considered 2 applications and be independent of each other? 如果我设置一个静态变量,在这种情况下,一个log4net追加程序的日志文件路径在运行时在每个站点中的值都不同,这些值是否会相互覆盖,还是将其视为2个应用程序,并且彼此独立?

From the TechNet Article on IIS Application Pools 摘自IIS应用程序池上TechNet文章

An Internet Information Services (IIS) application pool is a grouping of URLs that is routed to one or more worker processes. Internet信息服务(IIS)应用程序池是一组URL,这些URL路由到一个或多个辅助进程。 Because application pools define a set of Web applications that share one or more worker processes, they provide a convenient way to administer a set of Web sites and applications and their corresponding worker processes. 因为应用程序池定义了一组共享一个或多个工作进程的Web应用程序,所以它们提供了一种方便的方法来管理一组网站和应用程序及其对应的工作进程。 Process boundaries separate each worker process; 进程边界将每个工作进程分开; therefore, a Web site or application in one application pool will not be affected by application problems in other application pools. 因此,一个应用程序池中的网站或应用程序将不受其他应用程序池中的应用程序问题的影响。 Application pools significantly increase both the reliability and manageability of a Web infrastructure. 应用程序池显着提高了Web基础结构的可靠性和可管理性。

Given that each application pool is its own set of worker processes, each static variable would be unique in that instance and should not be shared if setting the value at runtime. 假定每个应用程序池是其自己的工作进程集,则每个静态变量在该实例中都是唯一的,并且如果在运行时设置值,则不应共享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM