简体   繁体   中英

Why can't it find my BasicAuthenticationModule?

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?

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 (eg BasicAuthModule )
  • remove the existing BasicAuthorizationModeule module entry

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM