Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARR/URL Rewriter within a .net Web API application

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.

like image 606
MindingData Avatar asked Dec 05 '25 04:12

MindingData


1 Answers

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

RouteTable.Routes.IgnoreRoute("api/profiles/{*pathInfo}");
like image 77
MindingData Avatar answered Dec 08 '25 08:12

MindingData



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!