3

I have two applications. One of which is going to handle authentication across a range of products. Because of this, from each one I want to rewrite a URL from each individual website to our "authentication" project. It would look something like this.

http://www.mywebsite.com/api/profile/login -> http://www.myauthentication.com/api/profile/login.

So essentially pushing the request cross domain.

For this I have setup ARR and URL Rewriting in IIS. However I can't seem to get it to work, and I have a feeling URL Rewriting is not running on requests that would normally cause a 404. I think this because on a REDIRECT request (301 redirect), the config works perfectly. When I use a rewrite, I get a generic 404 page.

The rules configuration looks as per below :

<rules>
    <rule name="Route the requests for the Profile API." enabled="true" stopProcessing="true">
      <match url="^profiles/(.*)" />
      <action type="Rewrite" url="http://authentication.local/api/profiles/{R:1}" logRewrittenUrl="true" />
    </rule>
</rules>

It should be noted that I am using the WebAPI, not MVC, which I'm not sure if that is causing issues or not. Because the redirect works but not the rewrite, I'm sure I've got everything installed OK in IIS.

For ARR, I have simply ticked "Enable Proxy" but I am unsure if I need to do anything else.

MindingData
  • 11,924
  • 6
  • 49
  • 68
  • I have a similar issue. Interestingly enough it seems that URL Rewrite is not intercepting calls if there is an HTTP route mapped in the same app for that URL. So e.g. I have /api/... mapped for web API calls but have URL Rewrite rules that are supposed to rewrite everything. They don't catch calls to /api... Have you solved the issue? – Piedone May 07 '14 at 12:09
  • See: http://stackoverflow.com/questions/13885343/rewrite-rule-for-webapi-fails-because-of-extensionlessurlhandler and http://stackoverflow.com/questions/15437131/iis7-asp-net-mvc-webapi-rewrite – Piedone May 07 '14 at 12:13
  • Yes! We did get this working. Before you do your routes, you need to add RouteTable.Routes.IgnoreRoute("api/profiles/{*pathInfo}"); or similar to ignore your ARR URL. I'll post an answer. – MindingData May 07 '14 at 21:49

1 Answers1

2

I managed to solve this by adding an ignore route for ARR.

RouteTable.Routes.IgnoreRoute("api/profiles/{*pathInfo}");
MindingData
  • 11,924
  • 6
  • 49
  • 68
  • Great, thank you! BTW isn't that simply Ignore() (RouteCollection.Ignore())? – Piedone May 07 '14 at 22:40
  • Sorry to ask but where du you put this code snipped, no easy to find out !, maybe Global.asax ? i'm using webApi it looks like it does not ignore the route – benraay Feb 11 '19 at 14:11