为什么 PreSendRequestHeaders 和 PreSendRequestContent 运行不一致?

发布于 2024-07-16 07:01:25 字数 422 浏览 4 评论 0原文

在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请叫√我孤独 2024-07-23 07:01:25

这不是与 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.

桃扇骨 2024-07-23 07:01:25

也许它与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文