说我的网络应用中有一个文件夹,里面有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/
我可以检查HttpApplication
或HttpRequest
上是否有一些属性可以识别第二个请求是否存在? HeadersWritten
属性是内部的:(
由于