如何将我的 httpmodules 类与 httplistener Web 服务一起使用
这是我的http模块代码:
using System;
using System.Web;
using System.Collections;
public class MyCustomHttpModule: IHttpModule
{
public String ModuleName
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
application.EndRequest += (new EventHandler(this.Application_EndRequest));
}
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1>MyCustomHttpModule: Beginning of Request...</h1><br/>");
}
private void Application_EndRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1>MyCustomHttpModule: End of Request...</h1>");
}
public void Dispose()
{
}
}
httplistener 代码如下:
using HttpListener = HttpServer.HttpListener;
public class Loader
{
static void Main(string[] args)
{
HttpListener listener = HttpListener.Create(IPAddress.Any, 8089);
DynamicModuleUtility.RegisterModule(typeof(FileWebDAVModule));
listener.Start(5);
Thread.Sleep(90000000);
}
}
如何使用 httplistener 服务调用我的 httpmodule。请指导我。