一个.NET的Web API应用程序内的ARR / URL重写 [英] ARR/URL Rewriter within a .net Web API application

查看:676
本文介绍了一个.NET的Web API应用程序内的ARR / URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序。其中之一是要通过一系列的产品来处理身份验证。正因为如此,从每一个我想从各个网站的URL重写我们的认证项目。这将是这个样子。

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.

有关这个我已经安装ARR和URL在IIS重写。不过,我似乎无法得到它的工作,我有一种感觉URL重写未在运行的要求,通常会导致404我想,这是因为在一个重定向请求(301重定向)的配置完美的作品。当我使用了重写,我得到一个通用的404页。

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>

应该指出的是,我使用的WebAPI,没有MVC,这我不知道这是造成问题或没有。因为重定向作品,但不重写,我敢肯定,我已经得到了在IIS安装好了一切。

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.

有关ARR,我只是打勾启用代理服务器,但我不确定,如果我需要做别的。

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

推荐答案

我设法通过增加对ARR的忽视途径解决这个问题。

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

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

这篇关于一个.NET的Web API应用程序内的ARR / URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆