Root web.config used instead of site web.config
I had a situation on a dev server where all the ASP.Net applications we have started to fail at the same time.
After some investigation we found that calls the app settings, in 1.1 apps, and the connection strings collection in 2.0 apps all failed. The config files had the values, but the code was returning null.
After some head scratching and searching I thought that perhaps the root web.config was being used and the sites one ignored. To test out this theory I added the app settings required for one of the sites to the root web.config. This allowed the site to work.
After I had proven that I deleted th开发者_如何学Pythone settings from the root web.config and reset IIS. But now all of the sites are working again, even ones that do not rely on the settings I had previously added to the root web.config.
Can anyone explain why this might of happened? As far as I can tell touching the root web.config caused it all to work again, but I have no idea why or what caused the problem in the first place.
EDIT: This is on IIS 6.0 on Windows Server 2003 SP2
What could have happened depends on which version of IIS you were running. Root web.config is always read in ASP.NET, but web.config files in IIS subdirectories are only read when the subdirectory is defined as a web application in IIS. If you create a web.config in an IIS subdirectory that is not an application directory it will not be read.
I have never seen what you describe happen, but I imagine if the state of the running IIS process became corrupted and failed to recognize app dirs, the config system could miss the files in the subdirs.
I think this would be more likely to occur on IIS 5.x, such as Win2000 or XP than on Server 2008 or Windows 7.
精彩评论