我需要添加一个 IIS 模块进行一些处理。这是我的模块:
namespace MyNamespace
{
public class MyModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
//I hope to do some work here ONLY once for all requests
context.ReleaseRequestState += new EventHandler(myHandler);
}
#endregion
public void myHandler(Object source, EventArgs e)
{
//do some work...
}
}
}
我需要在 Init() 方法中做一些耗费资源的工作。我希望 Init 仅在网站中调用一次,并且仅在网站在 IIS 管理器中重新启动时再次调用。
这方面的专家能否告诉我 Init() 是否按我希望的那样工作?
谢谢!