views:

5550

answers:

2

I am trying to add

<location inheritInChildApplications="false">

to my parent web application's web.config but it doesn't seem to be working.

My parent's web.config has:

<configuration>
    <configSections>
    </configSections>

    // 10 or so custom config sections like log4net, hibernate,

    <connectionStrings>
    </connectionStrings>

    <appSettings>
    </appSettings>

    <system.diagnostics>
    </system.diagnostics>

    <system.web>
         <webParts>
         </webParts>
         <membership>
         </membership>

         <compilation>
         </compilation>
    </system.web>

    <location ..>
    <system.web>
        </system.web>
    </location>

    <system.webServer>
    </system.webServer>

My child web application is setup as an application in IIS, and is inheriting from the parent's web.config which is causing problems.

Where exactly should I place the

<location inheritInChildApplications="false">

so it ignores all the various web.config settings?

+3  A: 

It needs to go directly under the root <configuration> node and you need to set a path like this:

<?xml version="1.0"?>
<configuration>
    <location path="." inheritInChildApplications="false"> 
        <!-- Stuff that shouldn't be inherited goes in here -->
    </location>
</configuration>

A better way to handle configuration inheritance is to use a <clear/> in the child config wherever you don't want to inherit. So if you didn't want to inherit the parent config's connection strings you would do something like this:

<?xml version="1.0"?>
<configuration>
    <connectionStrings>
        <clear/>
        <!-- Child config's connection strings -->
    </connectionStrings>
</configuration>
Andrew Hare
I get this error "The configuration section 'configSections' cannot be read because it is missing a section declaration " in my parents web.config file.
Blankman
Can you post your config with the <location> element in it? I would also check out my edit and see if <clear/> might be a better approach for what you are trying to do.
Andrew Hare
it doesn't work when you put it right under <configuration>. You can wrap lets say <system.web> node but you can't just put it in the root like this.
CoffeeAddict
If you put it under <configuration> as the 2nd node in, you get "inheritInChildApplications attribute is not declared". So it's not a valid attribute at that level in the web.config. So how can you say this worked?
CoffeeAddict
A: 

I have a problem relation with this subject.

There is an web application.There are two directory at the root path one "tr" other "en" and a web.config configuration file at the root path.There are different web.configs at the "tr" and "en" child applications. root web.config file contents follows

sub directories web.config content follows

<add name="con" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db.mdb"
  providerName="System.Data.OleDb" />

</customErrors>
 <compilation debug="true"/>

but subdirectoriy applications not find class inside app_code and database inside app_data give errors follows

The type specified in the TypeName property of ObjectDataSource 'sql' could not be found.

What can ı do? thanks...

Yusuf