当我更改web.config时,出现HTTP错误500.19 - 内部服务器错误。

3
我想在我的网站上添加注册功能。当我在Web.config中添加配置时,运行项目时会出现以下错误:
HTTP错误500.19 - 内部服务器错误。无法访问请求的页面,因为该页面的相关配置数据无效。
详情:
 Detailed Error Information:
    Module     IIS Web Core
    Notification       Unknown
    Handler    Not yet determined
    Error Code     0x80070032
    Config Error       The configuration section 'authentication' cannot be read because it is missing a section declaration

我的 web.config:

<connectionStrings>      
    <add name="Model12" connectionString="data source=.\SQLEXPRESS;initial catalog=test123;integrated security=True; />
  </connectionStrings>

  <authentication mode="Forms">
 <forms loginUrl="~/FirstPage.aspx" timeout="2880" />
</authentication>

 <membership defaultProvider="CustomMembershipProvider">
     <providers>
     <clear />
     <add name="CustomMembershipProvider"
          type="MyMembershipProvider"
          connectionStringName="Model12"
          enablePasswordReset="true"
          maxInvalidPasswordAttempts="5"
          minRequiredPasswordLength="6"
          minRequiredNonalphanumericCharacters="0"
          passwordAttemptWindow="10"
          applicationName="/" />
     </providers>
</membership>

可能出了什么问题?

1
请确保authenticationmembership标签位于system.web标签内。而connectionStrings应该是configuration的直接子元素。 - Rahul Singh
请包含所有的web.config以验证标签是否格式正确,似乎它们不是。 - DanielV
1个回答

7

您从IIS获取的消息告诉您,它不认识您在“connectionStrings”元素下面使用的“authentication”元素。这是因为它应该在“system.web”元素内部,如下所示:

<system.web>
    <!-- Other system.web sections here-->
    <authentication mode="Forms">
        <forms loginUrl="~/FirstPage.aspx" timeout="2880"/>
    </authentication>
</system.web>

绝对完美 - Rush.2707

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接