Possible Duplicate:
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 BasicAuthenticationModule : IHttpModule
Ive added it to my web.config as such:
<system.webServer>
<modules>
<add name="MyBasicAuthenticationModule" type="Web_API.Modules.BasicAuthenticationModule, BasicAuthenticationModule" />
I get the following error when running this:
Server Error in '/' Application.
Could not load file or assembly 'BasicAuthenticationModule' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'BasicAuthenticationModule' or one of its dependencies. The system cannot find the file specified.
What am I doing wrong here?
You seem to have specified wrong assembly name for your module. When you write:
this means to load a class called
BasicAuthenticationModuleinside anWeb_API.Modulesnamespace within an assembly calledBasicAuthenticationModule. Is the project in which you defined this class calledBasicAuthenticationModule? I guess not. That’s why ASP.NET cannot load your module. You should specify the correct assembly name in which this module is defined.For example if your ASP.NET MVC application is called
MvcAPplication1the definition might look like this:The format of the type attribute is like this: