为什么 PreSendRequestHeaders 和 PreSendRequestContent 运行不一致?
在使用 HTTP 模块时,是否有人注意到管道中的最后两个事件——PreSendRequestHeaders 和 PreSendRequestContent——并不总是运行?
我已经验证绑定到 EndRequest 的代码将运行,但绑定到 PreSendRequestHeaders 或 PreSendRequestContent 时不会运行。
有理由吗? 我认为这可能是一个缓存问题(使用 304 Not Modified,您实际上并没有发送内容...),但我已经清除了缓存并确定服务器返回 200 OK,这表明它发送了内容。
这是一个问题,因为响应的 StatusCode 默认为 200,而我的理解是,直到这两个最终方法之前它不会更新为 404 或 206 之类的内容。 如果我在 EndRequest 期间检查 StatusCode,它将始终显示 200。
When working with HTTP modules, has anyone noticed that the final two events in the pipeline -- PreSendRequestHeaders and PreSendRequestContent -- don't always run?
I've verified that code bound to EndRequest will run, but will not when bound to either PreSendRequestHeaders or PreSendRequestContent.
Is there a reason why? I thought perhaps it was a caching issue (with a 304 Not Modified, you don't actually send content...), but I've cleared caches and determined that the server is returning 200 OK, which would indicate that it sent content.
This is a problem because the StatusCode of the response defaults to 200 and my understanding is that it doesn't get updated to something like a 404 or 206 until those two final methods. If I check the StatusCode during EndRequest, it will always read 200.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是与 IIS 7 集成管道有关吗?
有待验证,但我认为这些事件仅当 IIS 7 在集成管道中运行时才会触发。
isn't this related to the IIS 7 integrated pipeline?
To be verified, but I think that thoses events are only triggered when IIS 7 is running in integrated pipeline.
也许它与 HttpResponse.BufferOutput 有关。 如果关闭缓冲,则在这些事件触发时,似乎所有标头和部分内容都已发送。
Maybe it has to do with HttpResponse.BufferOutput. If buffering is turned off, it seems like all of the headers and some of the content would have already been sent by the time these events fire.