首页 > 解决方案 > AZURE 应用服务 web.config 中的多个处理程序

问题描述

Azure 应用服务的 web.config 中是否可以有多个 in 处理程序?

我有一个 .Net Core API 和一个 Angular Universal (Node.js) SPA 前端。如果可能,我想将它们保留在同一个应用服务上。为此,我认为我需要处理我的 web.config 文件。是否可以让所有 /api 请求都转到 .Net Core API,而对前端的请求由 Node / Angular Universal 处理?

这就是我现在在一个应用服务中为 .Net Core API 所拥有的:

<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>

这就是我在另一个应用服务中的 Angular Universal Node.js 前端所拥有的:

<handlers>
<add name="iisnode" path="server/main.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
      <rules>
          <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
              <match url="^main.js\/debug[\/]?" />
          </rule>
          <rule name="Angular Routes" 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="/index.html" />
          </rule>
      </rules>
</rewrite>

我想将这两者结合起来,以便所有 API 请求 (/api) 都被路由到 .Net Core API,所有前端请求 (/) 都转到 Node 处理程序并重写以使用 Index.html。

如果可能的话,谁能帮我解决这个问题?

标签: angularazureasp.net-coreweb-configangular-universal

解决方案


推荐阅读