Reputation: 223
Boiling this down to the simplest possible rule:
<rule name="Reverse Proxy" stopProcessing="true">
<match url="^external/(.*)" />
<action type="Rewrite" url="http://some-site/{R:1}" />
</rule>
("Enable Proxy" is checked in the ARR Server Proxy settings at the server level).
The above rewrite rule works fine in a very simple test app with a web.config containing the section, it works fine in a web forms app, but if I put the same rule into an MVC3 app (on the same machine, so identical config for IIS higher up) it never has any effect; the request flows through.
if it's just a rewrite (and not a reverse proxy) it works OK, e.g.,
<rule name="rewrite to internal" stopProcessing="true">
<match url="^internal/(.*)" />
<action type="Rewrite" url="different-internal/{R:1}" />
</rule>
...is fine.
I can get the reverse proxy rule to work if I add
routes.IgnoreRoute("external/{*pathInfo}");
in the Global.asax.cs class, so that my request for external/* doesn't hit the default controller, but I don't understand why. I think the URL rewrite module kicks in way before the Routing (see http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/) so I'd expect there not to be a conflict between them.
Is the Routing module adding in "virtual" rewrite rules to the URL rewrite module, that are overriding my declared rewrite rules?
Upvotes: 5
Views: 2740
Reputation: 1473
I had this exact same issue and it took me the entire day to find the solution.
Find: the ServoceModel tag in your Web.config file and add the serviceHostingEnvironment code as seen below:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
This will allow routes to be passed through to IIS to handle it.
One more tip, I recommend anyone having routing issues with their MVC projects to install Remote Debugger via NuGet. This will tell you what routes are being activated when.
Upvotes: 4