« Previous Next »

Thread: Outbound urls paths

Last post 11-06-2009 12:31 PM by anilr. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 11-05-2009, 5:47 PM

    • Devcon
    • Not Ranked
    • Joined on 09-27-2009, 11:51 AM
    • Posts 1

    Outbound urls paths

    Inbound urls are relative to web.config, as is told here:
    http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/

    But something similar doesn't seem to work for outbound urls; I always have to give the full absolute path including the root webapps path.

     

    For example:

    I have a webapp running under http://example.com/myApp/
    I want
    http://example.com/myApp/product.aspx?id=123
    to be mapped to
    http://example.com/myApp/product/123

    Then the inbound url rule would be:


    <rule>
        <match url="product/(\d+)" />
        <action type="Rewrite" url="product.aspx?id={R:1}" />
    </rule>


    As outbound rule, I would expect something like:
    <outboundRules>
        <rule name="Model" patternSyntax="ECMAScript" stopProcessing="false" preCondition="">
            <match filterByTags="A" customTags="" pattern="product\.aspx\?id=([0-9]+)" ignoreCase="true" negate="false" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
            <action type="Rewrite" value="product/{R:1}" />
        </rule>
    </outboundRules>

    But when the current browser url is http://example.com/myApp/product/123 this wil result in urls like:
    http://example.com/myApp/product/product/456 (double times the string "product")

    When putting a / in front of the action value, this will result in:
    http://example.com/product/456 (without the "myApp" webapp root).

    Using "~/product/{R:1}" also doesn't work.


    Is there a solution to use the action value pattern without a hardcoded webapp root ("myApp")? like is possible for inbound urls.
  • 11-06-2009, 12:31 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: Outbound urls paths

    Outbound url cannot be relative to the url for web.config - eg, you may have a url-rewrite rule defined at web.config for http://www.foo.com/abc but the outbound url is http://www.bar.com/def - how can we make it relative to the url for web.config?  With incoming rules, the url is guaranteed to be http://www.foo.com/abc/...

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
Page 1 of 1 (2 items)
Microsoft Communities