Is it possible to write an IIS URL rewrite rule that validates the contents of an HTTP message?

I need to separate some of the functionality from the old ISAPI library into another solution (most likely ASP.NET MVC). Rewriting the IIS7 URL sounds like the perfect candidate for the job, but it turns out I can't find a way to configure the rules the way I need. I need to write a rule that checks the contents of an HTTP message for a specific value.

i.e.

<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");

As a proof of concept, I was able to create an IHttpModule that parses the collection context.Request.Form and performs rewriting when certain parameters are available. I installed this module on my website and it works.

Instead of configuring the module, I would rather extend the existing Rewrite URL module to support checking the contents of HTTP Post as one of its rules. Is it possible?

+3
source share
1 answer

It seems impossible - it looks like only the headers are checked.

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

you can check specific values ​​of HTTP headers or server variables

If you can switch from POST to GET, you can check QUERY_STRING

0
source

Source: https://habr.com/ru/post/1748239/


All Articles