问题
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