I am learning to develop about creating a module for IIS to be use by web application. When I add my .dll to the /bin folder of web application that is hosted in IIS, it works.
But if I add this .dll to the root local server > Modules > Configure Native Modules and Register. It didn't work, when I run a web app the AppPool being use is stopped, the logs I'm seeing from the eventviewer is this:
Failed to find the RegisterModule entrypoint in the module DLL %windir%\TestWebAgent\x86\TestModule.dll. The data is the error.
This is my class that extends IHttpModule:
using System;
using System.Web;
namespace MyTestModule
{
public class TestModule : IHttpModule
{
public void Dispose()
{
throw new NotImplementedException();
}
public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
}
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1><font color=green>AUTHENTICATED</font></h1><hr>");
}
}
}
For anyone who is experiencing the same problem/issue. Lex Li's comment is true.
The class library I wrote is a managed module. That is not clear on almost all of the guide/tutorials I went to. So here's what I did to make it work:
Register .dll to Global Assembly Cache (GAC)
Use gacutility to register assembly to GAC (if you don't have gacutility.exe installed, you can download Windows SDK)
Add the module in web app's web.config: