So here's a funky Visual Studio behavior: On my root Web site (which is mostly static) I have my web.config set up to handle the root site configuration in a separate <location> element in order not to force the settings of the root site down into the many, many virtual directories/applications that are running on the site. So the core layout looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="webConnectionConfiguration" type="System.Configuration.NameValueSectionHandler,System,Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="wwBanner" type="System.Configuration.NameValueSectionHandler,System,Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<connectionStrings>
<add name="WestWindAdmin" connectionString="server=.;database=WestWindAdmin;integrated security=true;" providerName=""/>
</connectionStrings>
<location inheritInChildApplications="false">
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="Westwind.Tools"/>
<add namespace="Westwind.Web.Controls"/>
</namespaces>
</pages>
<trust level="Full"/>
<authentication mode="Windows"/>
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
</system.web>
<system.webServer>
<handlers>
<add name="West West Wind Web Connection" path="*.wst" verb="*" modules="IsapiModule" scriptProcessor="c:\westwind\wconnect\wc.dll" resourceType="Unspecified"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</location>
<wwBanner>
<add key="ConnectionString" value="server=.;database=WestwindAdmin;integrated security=true;"/>
<add key="BannerManagerHandlerUrl" value="~/wwBanner.ashx"/>
<add key="TrackStatistics" value="True"/>
<add key="HomeUrl" value="~/admin/"/>
<add key="wwBannerTable" value="wwBanners"/>
<add key="wwBannerClicksTable" value="wwBannerClicks"/>
</wwBanner>
<appSettings>
<add key="LogFile" value="c:\westwind\raslog\raslog.txt"/>
<add key="AdminConnectionString" value="server=.;database=WestwindAdmin;integrated security=true;"/>
</appSettings>
</configuration>
The root site mappings basically handle all the non-virtual directories of the site so that I can have some ASP.NET functionality in the 'content' parts of my site. Things like link tracking, banner display and a few other maintenance applications run through these settings. The location tag as above guarantees that the root Web settings don't trigger down into the child virtuals which in the past has proved troublesome for some applications.
All this works great.
Except that Visual Studio doesn't correctly deal with this setup. Any change that is now made to web.config adds to the bottom of the config file rather than into the <location> specific tag. So adding a reference for example causes another <system.web> section to be added and ALL the references of the site now get readded there.
Not a big deal once you know but it took me a bit to figure out why all the sudden after adding a reference that the site would completely fail to run <s>.
It sure would be nice if VS could understand the Location tag, but I suspect this gets very difficult to parse. As it is the ASP.NET compiler complains about setting like Authentication in child Webs even though the authentication is hidden at the root (which was one of the main reasons that I needed to use the <location> tag.
On a side note - something has been screwed in my VS .NET 2008 setup in relation to editing the web.config file - whenever I press Ctrl-S to save the web.config document saves and CLOSES. Not sure WTF caused that behavior to crop up, nor do I have any idea on how to fix this <shrug>. Odd.
Other Posts you might also like