Why can't it find my BasicAuthenticationModule?

南楼画角 提交于 2019-12-01 11:04:45

问题


I'm trying to create my own implementation of a basic-authentication.

I have BasicAuthenticationModule.cs stored in my solution\Modules and its namespace is:

namespace Web_API.Modules
{
public class BasicAuthenticationModule2 : IHttpModule

Ive added it to my web.config as such:

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

Running this gets me: HTTP Error 500.19 - Internal Server Error - Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'BasicAuthenticationModule'

Does anyone have a clue?


回答1:


The reason is because there already is a built-in module called BasicAuthorizationModule that comes inside .NET.

You would need to either:

  • use a different Name (e.g. BasicAuthModule)
  • remove the existing BasicAuthorizationModeule module entry


来源:https://stackoverflow.com/questions/14667055/why-cant-it-find-my-basicauthenticationmodule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!