WinHost,配置错误,在应用程序配置或连接字符串中找不到“LocalSqlServer”

时间:2010-04-02 13:43:31

标签: c# asp.net sql sql-server

当我部署到我的winhost帐户并尝试使用成员资格提供程序登录时,我遇到了一个奇怪的问题,它在本地工作正常,但一旦它在内部网上就会中断。

Configuration Error

Description: An error occurred during the processing of a configuration file require to
service this request. Please review the specific error details below and modify your 
configuration file appropriately. 

Parser Error Message: The connection name 'LocalSqlServer' was not found in the
applications configuration or the connection string is empty.

Source Error: 
Source File: machine.config Line: 148

就好像我在app.config中的某个地方引用了'LocalSqlServer',但我这里没有提供者:

  <membership defaultProvider="SqlProvider">
  <providers>
    <clear/>
    <add name="SqlProvider" 
         connectionStringName="winhost" 
         enablePasswordRetrieval="false"
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false"
         passwordFormat="Hashed" 
         applicationName="TestAdmin" 
         minRequiredNonalphanumericCharacters="0"
         minRequiredPasswordLength="2" 
         type="System.Web.Security.SqlMembershipProvider" />
  </providers>
</membership>

<authentication mode="Forms"/>
<roleManager enabled="true">
  <providers>
    <clear/>
    <add name="AspNetSqlRoleProvider" 
         type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
         connectionStringName="winhost" 
         applicationName="TestAdmin"/>
  </providers>
</roleManager>

任何想法或帮助表示赞赏!

约什

2 个答案:

答案 0 :(得分:1)

查看错误消息的底部。它不是在谈论app.config;而是machine.config

<root drive>:\<windows>\Microsoft.NET\Framework\<version>\config\machine.config

这就是我的样子:

    <roleManager>
        <providers>
            <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </roleManager>

答案 1 :(得分:1)

我在将此ASP.NET错误部署到Winhost时遇到此错误。

答案是按照this link将此项添加到项目的web.config文件中。

<connectionStrings> 
<remove name="LocalSqlServer" /> 
<add name="LocalSqlServer" connectionString="Data Source=DBServerName;Integrated Security=false;Initial Catalog=DBName;User ID=DBLogin;Password=DBPassword" providerName="System.Data.SqlClient" />
</connectionStrings>

您必须添加两者 remove nameadd name