0

我正在尝试使密码的登录要求不那么严格。我在 web.config 文件中设置了所有属性,但由于某种原因,它不喜欢我的 Type 属性。我查看了 StackOverflow 以及其他网站上有关 web.config Membership 的所有其他帖子,它们似乎都与我为 Type 所做的完全一样。在我的搜索中,我似乎也找不到太多关于这个错误的信息。我只是不知道为什么会收到此错误:

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

 Parser Error Message: Attribute not recognized 'writeExceptionsToEventLog'

  Source Error:  
  Line 16:         <clear />
  Line 17:         <add name="AspNetSqlMembershipProvider"  
  Line 18:              type="System.Web.Security.SqlMembershipProvider"  
  Line 19:              connectionStringName="CafeWorksConnectionString"
  Line 20:              requiresQuestionAndAnswer="false"

这是我的 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>
  <appSettings>
    <add key="validationSettings:UnobtrusiveValidationMode" value="None"/>
  </appSettings>
  <system.web>
    <authentication mode="Forms" />
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
    <membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" 
             type="System.Web.Security.SqlMembershipProvider" 
             connectionStringName="CafeWorksConnectionString"
             requiresQuestionAndAnswer="false"
             enablePasswordRetrieval="false" enablePasswordReset="true"
             requiresUniqueEmail="false" passwordFormat="Hashed"
             minRequiredNonalphanumericCharacters="0" writeExceptionsToEventLog="false"
             minRequiredPasswordLength="4" passwordStrengthRegularExpression=""
             passwordAttemptWindow="10" maxInvalidPasswordAttempts="8"/>
      </providers>
    </membership>
  </system.web>
  <system.net>
    <mailSettings>
      <smtp from="Name@EmailHost.com">
        <network host="EmailHost" password="" userName="" />
      </smtp>
    </mailSettings>
  </system.net>
  <connectionStrings>
        <add name="CafeWorksConnectionString" connectionString="Data Source=DB;Initial Catalog=DBCatalog;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

如果有人知道如何纠正此错误,我将不胜感激。我完全不知道“writeExceptionsToEventLog”发生在哪里以及它为什么会导致我的错误。

谢谢!

4

1 回答 1

0

根据您的最后评论,您正在使用旧版会员资格提供程序。它使用存储过程和日期。

请使用使用实体框架的ASP.NET 通用提供程序。

如何更换为新会员提供者

我假设您正在实施一个新项目。原因是新的 Universal Provider 创建了没有前缀 aspnet_ 的表,这很好。但是,如果您正在处理现有项目,它将破坏与自定义表的关系。

按照 Scott Hanselman 的文章,首先进行一个新的测试项目。

基本上,您只需要更换name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider".

由于您替换了名称,因此您还需要将 defaultProvider 设置为 -defaultProvider="DefaultMembershipProvider"

其余的都是一样的。New Universal Provider 使用Entity Framework Code First,因此如果尚未创建所需的表,它将自动为您创建它们。请注意,它不使用存储过程。

美妙之处在于您无需运行 aspnet_regsql.exe 即可创建架构和存储过程。

于 2013-08-14T15:10:44.560 回答