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.

3
  • 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? Commented May 7, 2014 at 12:09
  • See: stackoverflow.com/questions/13885343/… and stackoverflow.com/questions/15437131/… Commented May 7, 2014 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. Commented May 7, 2014 at 21:49

1 Answer 1

2

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

RouteTable.Routes.IgnoreRoute("api/profiles/{*pathInfo}");
Sign up to request clarification or add additional context in comments.

2 Comments

Great, thank you! BTW isn't that simply Ignore() (RouteCollection.Ignore())?
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.