Angular 先路由,否则mvc路由

Angular routing first, mvc routing otherwise

我有一个应用程序使用 Angular 和 node.js(IIS 7.5 上的 运行)用于 UI,然后是 .NET Web API对于所有端点调用。

Angular 路由按预期工作,API 路由按预期工作...当 运行 API 通过 Visual Studio/IIS Express和 ng serve 启动 UI。当然,它们 运行 在两个不同的端口上。

目标是部署到单个 IIS 网站,不幸的是,部署到单个应用程序池。

鉴于 http://www.mycoolapplication.com for the UI and http://www.mycoolapplication.com/api 的 URL 对于 API,我如何让 Angular 忽略任何匹配 api 和所有 api的children?

我正在浏览 Routes 模块,希望能够向 path object 添加一些内容,但似乎没有任何内容可以添加从 Angular 路由 table.

完成 排除 某事

将此 web.config 放入您的前端应用程序(包含 index.html 的文件夹)。它将处理除 api/*.

之外的所有请求
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="API Rule" stopProcessing="true">
          <match url="^(api)(.*)$" />
          <action type="None" />
        </rule>
        <rule name="Angular" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>