无连接字符串可能会在应用程序配置文件中找到(但的确存在) [英] No connection string could be found in the application config file (But it Does Exist)

查看:298
本文介绍了无连接字符串可能会在应用程序配置文件中找到(但的确存在)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我发布到IIS的Web API项目,它抱怨有我的配置文件中的特定名称的连接字符串。我验证有这么绝不能拿起它的网络API项目在我的web.config文件中的条目。我能够在本地运行同样的web.config文件中使用Visual Studio 2013。

我深知引用的启动项目必须有连接字符串和是这样对我。我验证了我的网络API项目有如下(我成功地使用我的本地机器上的相同)。

连接字符串

 <&是connectionStrings GT;
    <添加名称=MYDB connectionString=\"metadata=res://*/MyDB.csdl|res://*/MyDB.ssdl|res://*/MyDB.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源=本地主机\\ MYDB;初始目录= MYDB;集成安全=真; MultipleActiveResultSets = TRUE;应用=&的EntityFramework放大器; QUOT;的providerName =System.Data.EntityClient/>
< /&是connectionStrings GT;

时它在抱怨另一个配置文件中的其他地方的服务器上?

我已经尝试过在<一的建议href=\"http://stackoverflow.com/questions/23207182/no-connection-string-could-be-found-in-the-config-file-but-it-is-there\">this 的问题,没有运气。


解决方案

  

仓内只有一个web.config文件 -


您的web.config文件应在同一文件夹中的Global.asax,packages.config而不是在bin文件夹中。

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.

解决方案

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.

这篇关于无连接字符串可能会在应用程序配置文件中找到(但的确存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆