排除某些网页使用一个HTTP模块 [英] Exclude certain pages from using a HTTPModule

查看:208
本文介绍了排除某些网页使用一个HTTP模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有排除使用一个HTTP模块某些网页的好办法?

Is there a good way to exclude certain pages from using a HTTP module?

我有一个使用自定义的HTTP模块来验证会话的应用程序。该HTTP模块设置这样的web配置:

I have an application that uses a custom HTTP module to validate a session. The HTTPModule is set up like this in web config:

<system.web>
  <!-- ... -->
  <httpModules>
    <add name="SessionValidationModule"
       type="SessionValidationModule, SomeNamespace" />
  </httpModules>
</system.web>

要排除的页面模块,我试图做这个(没有成功):

To exclude the module from the page, I tried doing this (without success):

<location path="ToBeExcluded">
  <system.web>
    <!-- ... -->
    <httpModules>
      <remove name="SessionValidationModule" />
    </httpModules>
  </system.web>
</location>

有什么想法?

推荐答案

您可以使用一个HttpHandler,而不是一个HTTP模块。处理程序允许您指定的路径,当你在Web.Config中声明它们。

You could use an HTTPHandler instead of an HTTPModule. Handlers let you specify a path when you declare them in Web.Config.

<add verb="*" path="/validate/*.aspx" type="Handler,Assembly"/>

如果必须使用HTTP模块,你可以只检查请求的路径,如果它是一个被排除在外,绕过验证。

If you must use an HTTPModule, you could just check the path of the request and if it's one to be excluded, bypass the validation.

这篇关于排除某些网页使用一个HTTP模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆