No connection string could be found in the application config file (But it Does Exist)

半世苍凉 提交于 2020-01-06 15:04:21

问题


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=&quot;data source=localhost\MyDB;initial catalog=MyDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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:


  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.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!