Question

On my iis7 box, I have a url rewrite rule in my web.config that keeps all of my urls lowercase:

<rule name="LowerCaseRule1" stopProcessing="false">
    <match url="^((?=.*[A-Z]).*\.aspx)(.*)" ignoreCase="false" />
    <action type="Redirect" url="{ToLower:{R:1}}{R:2}" />
</rule>

This has been working well, but it also rewrites my AJAX WebMethod calls when they contain any capitals letters. Consequently the methods don't get called. An obvious solution is to keep all WebMethods lowercase, but it would be way more appropriate to attack it on the front from the rewrite's regex.

Currently:

/Default.aspx ==> /default.aspx

/Default.aspx/UpdateOrder ==> /default.aspx/updateorder

I'd like the latter example to rewrite to /default.aspx/UpdateOrder

My regex skills just can't get me there.

Thanks in advance, John

Was it helpful?

Solution

I set this problem aside and came back to it much later. I added a negate condition and it seems to do the trick:

<rule name="LowerCaseRule1" stopProcessing="false">
     <match url="^((?=.*[A-Z]).*\.aspx)(.*)" ignoreCase="false" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_URL}" matchType="Pattern" pattern="^([^A-Z]+\.aspx/)(.*)" ignoreCase="false" negate="true" />
     </conditions>
   <action type="Redirect" url="{ToLower:{R:1}}{R:2}" />
</rule>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top