Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.config in virtual directory is not overriding parent website's Web.config

I've got a website which has a virtual directory that also includes a website, and when I try to launch a page from the virtual directory, I receive an IIS 7.5 error that the name (from the connection string) is already in the collection. This wasn't a problem before I added a domain user as the Identity in the app pool. Does anyone know why this is happening? I was under the impression that sub level application's web.config overrides the parent's by default. And again, this was once working until I added a custom Identity.

The error on the page is "Parser Error Message: The entry 'dbname' has already been added."

Where the dbname is in both connection strings (i.e. parent and virtual directory). I can't delete one of the connection strings because the virtual directory is only created for test purposes, but in production it runs as its own website.

like image 399
u84six Avatar asked Mar 22 '13 00:03

u84six


1 Answers

A sub web.config doesn't override a parent regardless of application. All web.configs will stack up all the way to the root of the primary application. In order for sub-application folder to make use of a connection string key that is already in use it must first be removed or all connection strings must be cleared. If you want this to be a truly stand alone application as a child add this to your connection strings:

<connectionStrings>
    <clear />
    <your connection string>
<connectionStrings>

If you just want to remove the single connection string use this:

<remove key="yourConnectionStringName" />
like image 174
Joel Etherton Avatar answered Sep 21 '22 22:09

Joel Etherton