Previous Next

Thread: Rewrite rules render querystring useless

Last post 07-25-2008 1:57 AM by cichanlx. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 07-25-2008, 1:53 AM

    Rewrite rules render querystring useless

    Hello.  I have a URL that functions fine with no rewrite rules.

    http://www.mysite.com/manufacturer.aspx?mfg=h

    The aspx page filters a SQLDataSource result set by the querystring ID.  If I turn on just the following 2 (extensionless page) rules (see below), my URL looks like this:

    http://www.mysite.com/manufacturer?mfg=h

    ...However, the aspx page then behaves as if there is no querystring parameter of mfg.  In my code-beside, the following expression is true, but should be false:

    String.IsNullOrEmpty(Request.QueryString("mfg"))

    My 2 rules -------------

    <rule name="RedirectToExtensionlessURLs" enabled="true">

    <match url="(.*).aspx" />

    <conditions>

    <add input="{REQUEST_FILENAME}" matchType="IsFile" />

    </conditions>

    <action type="Redirect" url="{R:1}" appendQueryString="true" redirectType="Permanent" />

    </rule>

    <rule name="ExtensionlessURLs" enabled="true">

    <match url="(.*)" />

    <conditions>

    <add input="{REQUEST_FILENAME}" negate="true" pattern="(.*).aspx" />

    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

    </conditions>

    <action type="Rewrite" url="{R:1}.aspx" appendQueryString="false" />

    </rule>

    ---------

    Cordially,

    Lee

  • 07-25-2008, 1:57 AM In reply to

    Re: Rewrite rules render querystring useless

    Okay, as soon as I saw my post, it became clear that the ExtensionlessURLs rule had appendQueryString set to false.  I just tried setting it to true, and my page now works.

     

    It's a bit confusing that with it set to false, the querystring parameter/value pair still shows in the address bar URL; yet, it was not passed through to ASP.Net.  I guess that could make sense, though.

    Cordially,

    Lee

Page 1 of 1 (2 items)
Page view counter