I’m trying to write URLs inside my Web Applications both In- and Outbound using IISs URLRewriter like so:
www.domain.net/SomeSite.aspx to www.domain.net/SomeSite using this RegEx for Inbound:
^([A-Za-z0-9]+)([\?A-Za-z0-9=&]+)?$, much to my surprise, this actually works, also for URLs such as www.domain.net/SomeSite.aspx?abc=1 => www.domain.net/SomeSite?abc=1 using this Rewrite Action: {R:1}.aspx?{R:2}
But now, for Outbound, I’d like to have the same effect so the user actually sees www.domain.net/SomeSite even though my webapplication might be referencing ~/SomeSite.aspx internally.
I use the following RegEx for that:
^([A-Za-z0-9]+).aspx([\?A-Za-z0-9=&#]+)?$ and rewrite the URL like so: /{R:1}{R:2}
In general this works, alas, it does not for e.g. Response.Redirect executed in CodeBehind and neither does it work for PostBackUrls from asp:Buttons.
Does anyone have any idea how to rewrite this outbound rule so it actually catches every link regardless of how I referenced it?
Thanks,
Dennis
Edit:
Some examples since I suppose I wasn’t quite as clear as I thought:
User enters www.domain.com/Login in Browser, Inbound-Rule catches and redirects to www.domain.com/Login.aspx yet shows /Login in the Address Bar, this behaviour is fine.
However, when I click on i.e. an asp:Button with PostBackUrl Login.aspx the Address Bar will show Login.aspx instead of the desired Login, how to get exactly this behaviour?
As it turns out, the only thing I needed to do was add an Inbound Redirect Rule and set
stopProcessingto true for both rules. Here’s the result: