有关会话等的 httpmodule 问题

发布于 2024-12-12 11:11:27 字数 278 浏览 0 评论 0原文

我在我的 asp.net Web 应用程序、iis7、.net 4.0 等中设置了 httpmodule。我有 2 个问题想要解决。

通过对 httpmodule 的调试,我发现该模块被 ScriptResource.axd 调用。它在被调用时运行。有什么办法可以阻止这种情况或“将其关闭”吗?我想让该模块为我的一些 httphandlers、.asmx 服务和 aspx 页面请求运行,但不希望产生脚本资源处理程序调用的开销。

其次,会话状态在 HttpModule 中是否可用?如果是,它在哪些事件中可用?

I have a httpmodule set up in my asp.net web application, iis7, .net 4.0 etc. I have 2 issues I would like to resolve.

From debugging of the httpmodule, I have found that the module gets called for ScriptResource.axd ie. it runs when this is called. Is there any way I can prevent this or "turn it off"? I want to have the module run for some of my httphandlers, .asmx services and aspx page requests but dont want the overhead of being called for scriptresource handlers.

Secondling, is session state available in HttpModules and if so, what events is it available at?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

软的没边 2024-12-19 11:11:27

如前所述,HttpModules 对应用程序中的所有请求启用,因此您唯一能做的就是检查 HttpModule 中的传入 url,然后决定采取什么操作基于此。

会话状态在 AcquireRequestState 事件期间加载,因此从 HttpModule 检查会话状态的最早机会是 PostAcquireRequestState 事件。会话状态在引发 ReleaseRequestState 事件时保留,因此您对会话所做的任何更改都应在该点之前进行。因此,您可以在这些之间的HttpApplication 管道期间随时访问会话状态两个事件

As already mentioned, HttpModules are enabled for all requests in an application so the only thing you can do is to inspect the incoming url in the HttpModule and then decide what action to take based on that.

Session state is loaded during the AcquireRequestState event so the earliest opportunity to inspect it from a HttpModule is the PostAcquireRequestState event. Session state is persisted at the point that the ReleaseRequestState event is raised, so any changes you make to the session should be made before that point. You can therefore access session state at any point during the HttpApplication pipeline between those two events

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