【问题标题】:Is it possible to write an IIS URL Rewrite Rule that examines content of HTTP Post?是否可以编写一个检查 HTTP Post 内容的 IIS URL 重写规则?
【发布时间】:2011-02-27 01:03:08
【问题描述】:

我需要将一部分功能从旧版 ISAPI dll 拆分到另一个解决方案(很可能是 ASP.NET MVC)。 IIS7 的 URL Rewrite 听起来像是该工作的完美候选人,但事实证明我找不到按照我需要的方式配置规则的方法。我需要编写一个规则来检查特定值的 HTTP 帖子的内容。

<form method="post" action="legacy_isapi.dll">
  <input name="foo" />
</form>
if (Request.Form["foo"] == "bar")
    Context.RewritePath("/some_other_url/on_the_same_machine/foo/bar");

作为概念证明,我能够创建一个 IHttpModule 来检查 context.Request.Form 集合并在存在某些参数时执行重写。我在我的网站上安装了这个模块,它可以工作。

然而,我宁愿扩展现有的 URL 重写模块,而不是自定义模块,以支持将 HTTP Post 的内容作为其规则之一进行检查。这可能吗?

【问题讨论】:

    标签: c# iis-7 url-rewriting


    【解决方案1】:

    似乎不可能 - 似乎只检查了标题。

    http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/#Rewrite_Rules_Overview

    您可以检查 HTTP 标头或服务器变量的某些值

    如果您可以从 POST 切换到 GET,则可以检查 QUERY_STRING

    【讨论】:

      猜你喜欢
      • 2011-04-21
      • 2020-12-13
      • 2014-10-27
      • 2020-01-05
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      相关资源
      最近更新 更多