【问题标题】:Why can't it find my BasicAuthenticationModule?为什么找不到我的 BasicAuthenticationModule?
【发布时间】:2013-02-02 22:11:33
【问题描述】:

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

我有BasicAuthenticationModule.cs 存储在我的solution\Modules 中,它的命名空间是:

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'

有人知道吗?

【问题讨论】:

  • BasicAuthenticationModule2 ?
  • 我现在得到'无法加载文件或程序集'BasicAuthenticationModule'或其依赖项之一。系统找不到指定的文件。'
  • 类型不是Web_API.Modules.BasicAuthenticationModule2吗?
  • 看起来很垃圾,但我将我的课程重命名为“BasicAuthenticationModule2”。我的 'system.WebServer' 'modules' 现在看起来像:'' 我仍然得到:'Could not load file or assembly 'BasicAuthenticationModule2' or它的依赖项之一。系统找不到指定的文件。'
  • 试试&lt;add name="BasicAuthenticationModule2" type=" Web_API.Modules.BasicAuthenticationModule2"/&gt;

标签: c# asp.net asp.net-mvc-4 basic-authentication


【解决方案1】:

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

您需要:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-30
    • 2021-01-09
    • 1970-01-01
    • 2019-07-09
    • 1970-01-01
    • 2014-04-21
    • 2013-09-17
    相关资源
    最近更新 更多