« Previous Next »

Thread: Detect question mark symbol

Last post 10-13-2008 1:31 PM by ruslany. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 10-10-2008, 12:16 AM

    • icebits
    • Not Ranked
    • Joined on 06-08-2005, 3:29 AM
    • Posts 7

    Detect question mark symbol

    How to let rewriter detect question mark symbol in pattern?

    My rule as below:

    <rule name="Page3" stopProcessing="true">
      <match url="^(Page3)(\?.*?)??$" />
      <action type="Rewrite" url="/Routing.aspx?url={R:1}&amp;ext=ascx" />
     </rule>

    I have test the pattern in IIS URL Rewriter and it is able to detect "Page3" or "Page3?" but when i type in "Page3?", it can't detect. What's wrong with my rule?

     

  • 10-10-2008, 1:35 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 660

    Re: Detect question mark symbol

    This article explains how the URL parts can be accessed from rewrite rule. If URL contains "?" then whatever is before the "?" will be used as a URL path and will be given as an input for the rule pattern. This means that the rule pattern specified in the <match> element of the rule will never be able to determine if the URL contains "?" symbol.

    If you want to detect if the presence of the "?" you could add a condition that checks the REQUEST_URI server variable. That server variable contains the entire requested URL path including query string.

    http://ruslany.net
  • 10-13-2008, 12:35 AM In reply to

    • icebits
    • Not Ranked
    • Joined on 06-08-2005, 3:29 AM
    • Posts 7

    Re: Detect question mark symbol

    I have no way to do it as advised.

    But if i change the

    HttpContext.Current.RewritePath(Request.ServerVariables("HTTP_X_ORIGINAL_URL"), True)

    with

    HttpContext.Current.RewritePath(customurl, Nothing, "customparam=something", True)

    my destination page able to retrieve the querystring rewrite from url rewriter and also querystring from url. And also i need to replace original url with custom url that without any parameter.

    Maybe my rewriter rule invalid therefore i need to do the above mentioned workaround.

  • 10-13-2008, 1:31 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 660

    Re: Detect question mark symbol

    Can you explain what your rewrite rule is supposed to do?

    http://ruslany.net
Page 1 of 1 (4 items)
Microsoft Communities