使用带有 .html 文件扩展名的 HttpModule

发布于 2024-07-11 21:34:35 字数 226 浏览 5 评论 0原文

我需要访问 httpmodule 中的会话。 当我的页面是 aspx 页面时它工作正常,但是当请求 url 是 .html 时 context.session 为 null 我已将 .html 映射为使用 aspnet_isapi.dll

我正在尝试访问 context_PreRequestHandlerExecute 中的会话,并且我有 httpmodule 继承 IReadOnlySessionState

I need access to session in httpmodule. It works fine when my page is a aspx page, but context.session is null when the request url is .html
I have .html mapped to use aspnet_isapi.dll

I am trying to access session in context_PreRequestHandlerExecute and I have httpmodule inherit IReadOnlySessionState

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

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

发布评论

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

评论(2

肤浅与狂妄 2024-07-18 21:34:35

根据我的经验, IReadOnlySessionState 和 IRequiresSessionState 仅适用于 HttpHandlers。

有关如何实现它的信息,请参阅以下 SO 链接:

我可以访问会话状态吗来自 HTTPModule?

IIS HttpModule 无法设置会话

From my experience IReadOnlySessionState and IRequiresSessionState only apply to HttpHandlers.

See the following SO links on how to implement it:

Can I access session state from an HTTPModule?

IIS HttpModule unable to set Session

无声情话 2024-07-18 21:34:35

它不适用于 HTML 扩展,因为 aspnet_isapi.dll 不处理扩展,而是处理 .aspx 页面。

您应该使用其他扩展而不是使用 HTML,并且应该在 IIS 应用程序配置(网站属性 -> 主目录选项卡 -> 配置按钮 -> 映射选项卡)中注册新扩展。 使用 .aspx 作为示例添加您自己的扩展名。

It does not work with HTML extension because aspnet_isapi.dll does not handle the extension, but handels .aspx pages.

You should use another extension instead of using HTML and you should register the new extension in IIS Application Configuration (Web Site Properties -> Home Directory tab -> Configuration button -> Mappings tab). Use .aspx as an example to add your own extension.

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