ASP.NET url rewrite rule that ignores AJAX requests

How can I create a URL rewrite rule that applies lowercase URLs except when the request is an AJAX request, i.e. when the X-Requested-With header is XMLHttpRequest?

+3


source to share


1 answer


Found it out.



        <rule name="LowerCaseURL" stopProcessing="true">
            <match url="[A-Z]" ignoreCase="false" />
            <conditions logicalGrouping="MatchAll">
                <add input="{HTTP_X_Requested_With}" pattern="^XMLHttpRequest$" negate="true" />
            </conditions>
            <action type="Redirect" url="{ToLower:{URL}}" />
        </rule>

      

+3


source







All Articles