为什么可以';它找不到我的基本身份验证模块

本文关键字:我的 身份验证 模块 找不到 为什么 | 更新日期: 2023-09-27 17:57:33

我正在尝试创建自己的基本身份验证实现。

我的solution'Modules中存储了BasicAuthenticationModule.cs,其名称空间为:

namespace Web_API.Modules
{
public class BasicAuthenticationModule2 : IHttpModule

我把它添加到了我的web.config中:

<system.webServer>
    <modules>
      <add name="BasicAuthenticationModule" type="Web_API.Modules.BasicAuthenticationModule, BasicAuthenticationModule"/>

运行此程序使我:HTTP Error 500.19 - Internal Server Error - Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'BasicAuthenticationModule'

有人知道线索吗?

为什么可以';它找不到我的基本身份验证模块

原因是.NET.中已经有一个名为BasicAuthorizationModule的内置模块

您需要:

  • 使用不同的Name(例如BasicAuthModule
  • 删除现有的BasicAuthorizationModeule模块条目