登录管理区域时出现配置错误

时间:2014-01-29 12:52:22

标签: asp.net web-config aspnetdb deploying

在web配置文件中配置我的asp.net connectionString后我的网站运行但是当我尝试登录我的管理区域时收到错误消息

  

配置错误

     

描述:处理为此请求提供服务所需的配置文件时发生错误。请查看下面的具体错误详细信息并相应地修改配置文件。

     

分析程序错误消息:在应用程序配置中找不到连接名称“MyconnectionStringName”,或者连接字符串为空。

来源错误:

<providers>
Line 16:        <remove name="AspNetSqlMembershipProvider"/>
Line 17:        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="MyConnectionStringName" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 18:      </providers>
Line 19:    </membership>

但它在Local Server上运行良好。

我的web.config文件

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>

    <connectionStrings>
  <add name="AsconConnectionString" connectionString="LoginDetails"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
<customErrors mode="Off"/>
   <membership>
     <providers>
       <remove name="AspNetSqlMembershipProvider"/>
       <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ConnectionDetails" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
     </providers>
   </membership>
        <roleManager enabled="true" />
  <authentication mode="Forms" />
  <compilation debug="false" targetFramework="4.0"/>
    </system.web>
</configuration>

1 个答案:

答案 0 :(得分:0)

我有同样的问题。它将在本地工作,但要在服务器上运行,您需要将模式版本更新到您的数据库。你不会直接使用aspnetdb.mdf

您可以找到该脚本并使用您的数据库进行更新。希望这可以解决您的问题

从此链接下载此脚本 https://drive.google.com/file/d/0B2D0SiDP8hTFN2tDX04zYVp6OXc/edit?usp=sharing

现在您需要将其添加到配置文件

<system.web>
<!-- membership provider -->
<roleManager enabled="true">
  <providers>
    <clear/>
    <add name="AspNetSqlRoleProvider"
        connectionStringName="myportalconstr"
        applicationName="/"
        type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</roleManager>
<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
        connectionStringName="myportalconstr"
        applicationName="/"
    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,           Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </providers>
</membership>

 <trust level="Full" /> 
  <customErrors mode="Off" defaultRedirect="home"/>
  <anonymousIdentification enabled="true"/>

  <profile enabled="true">
  <providers>
    <clear/>
    <add applicationName="/myportal"  connectionStringName="myportalconstr"     name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider"/>
  </providers>

</profile>
</system.web>