问题
I have a web API project I published to IIS and it complains there is no connection string with a specific name in my config file. I verified there is an entry in my web.config file of the web API project so it must not be picking it up. I was able to run this same web.config file locally using Visual Studio 2013.
I am well aware the referenced start up project must have the connection string and that is the case for me. I verified my web API project has the connection string below (same one I used successfully on my local machine).
<connectionStrings>
<add name="MyDB" connectionString="metadata=res://*/MyDB.csdl|res://*/MyDB.ssdl|res://*/MyDB.msl;provider=System.Data.SqlClient;provider connection string="data source=localhost\MyDB;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionStrings>
Is it complaining about another config file somewhere else on the server?
I already tried the suggestions in this question with no luck.
回答1:
- If your project is published in a folder on IIS, and a config file exists in an uppermost folder, those values may be conflicting.
- If another config file exists, try enabling the option "Remove additional files at destination" when publishing. This option is location under Settings -> File Publish Options
回答2:
Inside bin there is only one web.config file -
Your web.config file should be in same folder as Global.asax, packages.config and not in bin folder.
来源:https://stackoverflow.com/questions/29854374/no-connection-string-could-be-found-in-the-application-config-file-but-it-does