简体   繁体   中英

Find out which web.config(s) have been loaded

I'm encountering an error indicating that the web.config being loaded by this particular sub-project of my solution has a connectionstring that conflicts with an existing entry from an already-loaded web.config (Exception message is: Additional information: The entry 'connStr' has already been added. )

Is there a way to easily find out the list of all web.configs loaded/being loaded, so that I can ascertain where to conflict is arising

There is only one web.config that will be loaded, however, it will inherit from your machine configuration. For IIS this is here:

%windir%\Microsoft.NET\Framework\framework_version\CONFIG\machine.config

And for IIS Express in one of these places:

%userprofile%\documents\iisexpress\config\applicationhost.config
%userprofile%\my documents\iisexpress\config\applicationhost.config
$(solutionDir)\.vs\config\applicationhost.config (only for Visual Studio 2015 and above)

So you can remove the duplicate from there, or add a remove entry in your web.config , for example:

<connectionStrings>
  <remove name="MyConnection" />
  <add name="MyConnection" connectionString="..." providerName="System.Data.SqlClient" />
</connectionStrings>

I've had this problem before, I added inheritInChildApplications="false" in my main web.config. This way I know that my sub web.config will not have any conflict.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM