locked
Ajax and IIS rewrite rule conflict RRS feed

  • Question

  • User219851468 posted

    On my website i have added a url rewrite that  forces lowercase url.

    The issue is that it causing an issue with my ajax service call.

    Is there any other way of setting up rewrite rules easily?

    Tuesday, January 6, 2015 4:59 PM

Answers

  • User1918509225 posted

    Hi iperez_genius,

    you could configure the iis url rule like below to redirect your non-canonical to canonical URL that only lowercase character:

    <rule name="Convert to lower case" stopProcessing="true">
      <match url=".*[A-Z].*" ignoreCase="false" />
      <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
    </rule>

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 7, 2015 5:01 AM

All replies

  • User1918509225 posted

    Hi iperez_genius,

    you could configure the iis url rule like below to redirect your non-canonical to canonical URL that only lowercase character:

    <rule name="Convert to lower case" stopProcessing="true">
      <match url=".*[A-Z].*" ignoreCase="false" />
      <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
    </rule>

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 7, 2015 5:01 AM
  • User555306248 posted

    Hi,

    Please check the below reference to get Url Rewriting to work with Asp.Net Ajax:

    http://blog.angrypets.com/2007/01/aspnet_ajax_and.html

    If you take out the update panel and just do a normal post, you will see that the page will actually post directly to the unmapped url. That means your url rewriting is gone after a postback. That probably isn't what you would want, correct? If you implement a url rewriting scheme that actually changes what the form action is, so that posts go to the mapped url instead, not only will it avoid this issue, but it will work better in general. With this scheme, you have the possibility of the server side thinking the current request is in a different directory than the browser thinks, so things like ResolveClientUrl may report unusable paths. Any way you look at it, its best to avoid that scenario in the first place, so I recommend you take a look at the url rewriting post by Scott Guthrie,

    http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    Wednesday, January 7, 2015 10:47 PM