IIS URL重写最佳做法以进行匹配

时间:2018-08-14 17:56:30

标签: asp.net-mvc angular iis

我正在部署在ASP.NET MVC内运行的Angular 5.x应用程序。这样做时,我考虑了以下选项:

  • 将其部署在网站index.cshtml页面中的“ /”上
  • 创建自己的控制器(因此将其部署到“ / myapp /”)
  • 仅为Angular应用创建另一个虚拟目录。

第一个项目的问题是我有Angular路由以及所有挂在“ /”上的URL。

第二项可能没问题,但是我不确定重写回“ / subpage /”的效果如何。意见?

第三个可以简化URL重写,但会与基于SAML的身份验证发生冲突。

假设我选择第一个或第二个选择,是否有一种很好的方法将重写规则的一组URL列入白名单或黑名单。因此,我可以说这条规则适用于我所有的角度路由,或者不适用于我的非角度URL。

根据LexLi的建议,我正在尝试:

<rewrite>
  <rules>
    <rule name="Angular Routes" stopProcessing="true">
      <match url=".*" ignoreCase="true"/>
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_URI}" pattern="Account/*" negate="true" ignoreCase="true" />
        <add input="{REQUEST_URI}" pattern="SAML/*" negate="true" ignoreCase="true" />
        <add input="{REQUEST_URI}" pattern="Sites/*" negate="true" ignoreCase="true" />
      </conditions>
      <action type="Rewrite" url="/" />
    </rule>
  </rules>
</rewrite>

但是,比赛中的。*不起作用。如果我输入更具体的内容,它确实可以工作。

0 个答案:

没有答案
相关问题