tags:

views:

1357

answers:

4

I have a content management application in the root of my website, and I'm trying to use a different app (a billing application) under a sub-folder. Unfortunately, the web.config of the root site is interfering with the sub-app.

Is there a way to just disable web.config inheritance for a sub-folder?

Update: As linked by Stephen Burris, using the <location> tag can prevent inheritance for part of the web config, as follows:

<?xml version="1.0"?>
<configuration>
<configSections>
 ....
</configSections>
<location path="." inheritInChildApplications="false">
 <appSettings>
  ....
 </appSettings>
 <connectionStrings/>
 <system.web>
  ....
 </system.web>
 <system.codedom>
  ....
 </system.codedom>
 <system.webServer>
  ....
 </system.webServer>
</location>
<runtime>
 ....
</runtime>
</configuration>

The <configSections> and <runtime> sections will not accept being enclosed in the tag...so I guess this only does most of the job. Anybody know how to do it better?

A: 

is the application in the sub-folder a virtual directory? If not, make it so and that should ensure it has its own configuration settings.

Slace
It is not a virtual directory in this case. But I've tried that as well. The settings still seem to descend.
JoshRivers
Yes, this doesn't help.
David
+2  A: 

I would explicitly define all of the settings required - never assume that any setting is still set to the default value.

For example, if you're defining a connectionString include a <clear /> tag before the <add name=... />, etc. For Membership define all of the attributes, including the cookie name. And so on.

It may make the file a bit bigger but it will definitely help you avoid the "but it worked on my box" scenario too :-)

devstuff
Not exactly what I'd expect a good answer to be, but maybe it's the least bad option ...
le dorfier
+5  A: 

There is an attribute that you can use in the root web.config file to cause it not to have its contents become inherited by child applications.

inheritInChildApplications

Blog about inheritInChildApplications

MSDN article on ASP.NET Configuration File Hierarcy and Inheritance

Stephen B. Burris Jr.
+3  A: 

There is an issue with this approach. You can disable inheritance of items in < system.web /> but this does nothing to the < configSections /> part. Anybody know how to disable inheritance of items in < configSections />?

Ropstah