context.BeginRequestイベントを処理するカスタムIHttpModuleを使用して何かを実行できる場合があります。
public class MyHttpModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(OnBeginRequest);
}
protected void OnBeginRequest(object sender, EventArgs e)
{
var context = ((HttpApplication) sender).Context;
// do something here, use the context to get request info
}
public void Dispose()
{
}
}
次のように、HttpModuleをweb.configに登録する必要があります。
<httpModules>
<add name="MyHttpModule" type="MyProject.MyNamespace.MyHttpModule, MyProject"/>
</httpModules>