忽略 AJAX 请求的 ASP.NET URL 重写规则

Sco*_*son 3 asp.net iis ajax url-rewriting

我将如何创建强制小写 URL 的 URL 重写规则,除非请求是 AJAX 请求,即标头 X-Requested-With 具有 XMLHttpRequest 的值?

Sco*_*son 5

弄清楚了。

        <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>
Run Code Online (Sandbox Code Playgroud)