1

我刚刚开始在内部开发中的Visual Studio 2010 Professional中以调试模式运行我的ASP.NET MVC 4应用程序时收到此消息服务器。它一直工作到昨天。它刚刚从昨天开始。在应用程序配置中找不到连接名称'DefaultConnection',或者连接字符串为空

此外,这个错误只在我的桌面上。该应用程序在所有其他开发人员的机器,笔记本电脑和所有服务器上运行良好,无论是在调试模式还是在IIS上部署时。

实际的错误,我在死亡的黄色画面得到的是如下:

配置错误

说明:该请求提供服务所需的配置文件的处理过程中出现错误。请查看下面的具体错误细节并适当修改您的配置文件。

解析器错误消息:在应用程序配置中找不到连接名称'DefaultConnection',或连接字符串为空。

源错误:

Line 267: <membership defaultProvider="DefaultMembershipProvider"> 
Line 268:  <providers> 
Line 269:  <add name="DefaultMembershipProvider" 
         type="System.Web.Providers.DefaultMembershipProvider, 
          System.Web.Providers, Version=1.0.0.0, Culture=neutral, 
          PublicKeyToken=31bf3856ad364e35" 
         connectionStringName="DefaultConnection" 
         enablePasswordRetrieval="false" enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" requiresUniqueEmail="false" 
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" 
         minRequiredNonalphanumericCharacters="0" 
         passwordAttemptWindow="10" applicationName="/" /> 
Line 270:  </providers> 
Line 271: </membership> 

我检查了我的TFS的web.config的版本历史并没有,有也从来没有使用是该名称DefaultConnection永远的连接字符串。

回答

3

添加到您的web.config文件

<connectionStrings><add name="DefaultConnection" connectionString="Data Source=YourServername;Initial Catalog=YourDBname;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /></connectionStrings> 
+0

当然,我看到另一个线程(http://forums.asp.net/t/1838117.aspx/1?Issue+with+ASP+NET+web+site+configuration)建议同样的事情。我会。但我也想知道为什么这个错误突然出现了? – 2013-04-10 13:51:46

+0

您必须配置成员资格才能连接数据库,这就是为什么您要提供连接字符串名称 – incomplete 2013-04-10 13:54:05

0

我能想到的是,你可以浏览没有适当的成员连接字符串公共页面嘛。但是,只要浏览器需要验证页面,它就会失败。

它应该工作,如果你用工作连接字符串替换DefaultConnection

相关问题