Sql server 当站点移动到第三方主机时,SQL Server Express连接字符串错误

Sql server 当站点移动到第三方主机时,SQL Server Express连接字符串错误,sql-server,asp.net-mvc,asp.net-identity,Sql Server,Asp.net Mvc,Asp.net Identity,我在本地创建了一个使用Identity的ASP.NETMVC5站点。我最终将连接字符串移动到第三方托管服务器上的SQL Server,所有这些都运行良好。然后我设置了站点并发布到托管服务器,现在我不断收到与网络相关的错误 连接字符串使用应用程序的App\u Data目录中的数据库位置指定本地SQL Server Express实例 最初,我的App_Data文件夹中确实有一个本地SQL Server Express文件,但由于我将连接字符串移动到了SQL Server,我从App_Data文件夹

我在本地创建了一个使用Identity的ASP.NETMVC5站点。我最终将连接字符串移动到第三方托管服务器上的SQL Server,所有这些都运行良好。然后我设置了站点并发布到托管服务器,现在我不断收到与网络相关的错误

连接字符串使用应用程序的
App\u Data
目录中的数据库位置指定本地SQL Server Express实例

最初,我的
App_Data
文件夹中确实有一个本地SQL Server Express文件,但由于我将连接字符串移动到了SQL Server,我从
App_Data
文件夹中删除了
.mdf
文件,并且我的托管公司服务器上的文件夹是空的

最初的连接字符串名为
DefaultConnection
,我在
web.config
文件中将其注释掉。该连接确实尝试使用SQL Server Express,但不应使用它。我也在我的整个网站上搜索了
DefaultConnection
,但没有找到任何东西

寻找任何建议

这是
web.config
文件。
DefaulConnection
部分已注释掉,但我将其保留在配置文件中,以备需要。我的SQL Server连接是
DbConnection

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    </configSections>
    <connectionStrings>
        <!--<add name="DefaultConnection" connectionString="Data Source=DELL960\SQLEXPRESS;Initial Catalog=NTCC;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />-->
        <add name="DbConnection" 
             connectionString="Data Source=XX.XX.XX.XXX;Initial Catalog=northtxc_web;Integrated Security=False;User ID=northtxc_txsqladmin;Password=**********;" 
             providerName="System.Data.SqlClient" />
    </connectionStrings>
    <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
    <system.web>
        <customErrors mode="Off" />
        <trust level="Full" />
        <authentication mode="None" />
        <compilation targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2" />
        <roleManager enabled="true" />
    </system.web>
    <system.webServer>
        <modules>
            <remove name="FormsAuthentication" />
        </modules>
    </system.webServer>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
              <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
              <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
              <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>  
          <dependentAssembly>
              <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
          </dependentAssembly>
          <dependentAssembly>
              <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
              <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
          <dependentAssembly> 
               <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
               <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
              <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
              <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
               <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
               <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly> 
              <assemblyIdentity name="System.Web.Mvc"   publicKeyToken="31bf3856ad364e35" />
              <bindingRedirect oldVersion="1.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
          </dependentAssembly>
      </assemblyBinding>
    </runtime>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
            <provider invariantName="System.Data.SqlClient" 
                      type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>
</configuration>

您需要更新默认RoleProvider使用的连接字符串。MSDN有一个示例,假设您使用的是同一个提供程序:@Tieson…这不适合我,但使用该链接中的一个片段会导致我出现另一个错误,从而导致修复。所以,你的帖子最终为我指明了正确的方向。谢谢
@if (Roles.IsUserInRole("Admin"))