简体   繁体   中英

Static Variable in IIS ASP.NET application with 2 instances

I have a single code folder, c:\\some-ASPNETMVC-site

That folder is pointed to by 2 IIS7 Sites , each site has its own application pool .

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?

From the TechNet Article on IIS Application Pools

An Internet Information Services (IIS) application pool is a grouping of URLs that is routed to one or more worker processes. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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