ARR/URL Rewriter within a .net Web API application

跟風遠走 提交于 2019-12-12 18:16:01

问题


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.


回答1:


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

RouteTable.Routes.IgnoreRoute("api/profiles/{*pathInfo}");


来源:https://stackoverflow.com/questions/21667270/arr-url-rewriter-within-a-net-web-api-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!