ASP.NET请求生命周期

时间:2012-03-15 10:29:20

标签: asp.net

说我的网络应用中有一个文件夹,里面有index.html

/test
/test/index.html

以及以下Module

public class TestModule : IHttpModule
{
    public void Init(HttpApplication context)
    {
        context.ReleaseRequestState += context_ReleaseRequestState;
    }

    static void context_ReleaseRequestState(object sender, EventArgs e)
    {
        var application = sender as HttpApplication;

        // foo
    }
}

如果我向/test/index.html发出请求,context_ReleaseRequestState会触发并返回响应,那就太棒了。

如果我向/test/发出请求,context_ReleaseRequestState按上述方式触发,则会返回响应,然后context_ReleaseRequestState再次触发!

已经返回响应(并且连接已关闭等)。 HttpContext.Response对象上设置了以下属性:

HeadersWritten: true
Headers: Server=Microsoft-IIS%2f7.5

导致第二次调用的原因是什么?

第一次调用的Request FilePath属性为/test/index.html,第二次调用为/test/

我可以检查HttpApplicationHttpRequest上是否有一些属性可以识别第二个请求是否存在? HeadersWritten属性是内部的:(

由于

0 个答案:

没有答案
相关问题