tags:

views:

48

answers:

4

I am running into a problem with a web.config in a child project that has the same connection string setting as a parent. We have this in several of our web apps but there is one case where we want a child not to use the parent web.config. Is there a setting or command in the child web.config to ignore the parent web.config?

+3  A: 

In your web.config I think you want:

<location inheritInChildApplications="false">
<system.web>
...
</system.web>
</location>
Anthony
+3  A: 

If I understand your question correctly, you can also <clear /> out all previously defined connection strings from within your child web.config:

<configuration>
  <connectionStrings>
    <clear/>
    <add name="definedInParentButRedefinedHere" etc="..." />
  </connectionStrings>
</configuration>
Will
The <clear/> worked perfectly for our application, thanks for the help.
RJ
+2  A: 

If it's just a connection string you're having a problem with, and you want to keep the rest of the parent:

<connectionStrings>
    <remove name="DB2"/>
    <add name="DB2"
         providerName="System.Data.Odbc"
         connectionString="Database=DEVDB;Uid={0};Pwd={1};"/>
</connectionStrings>
Toby
A: 

Reading configuraiton value should be child to parent. When you try to read config vlaue then it wil first look into current foler web.config then parent folder confing and last machine config. Not sure why this default behaviour is not working for you! You dont need do anything to read first from child then form pareant as its default.

IBhadelia