IIS UrlRewriting и маршрутизация Angular 7

У меня проблема с маршрутизацией банкомата. Я хочу добавить карту сайта в свое угловое приложение, размещенное на Azure. В настоящее время web.config выглядит так:

<?xml version = "1.0" encoding = "utf-8"?>
<!--
     This configuration file is required if iisnode is used to run node processes behind
     IIS or IIS Express.  For more information, visit:

     https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
  <system.webServer>
    <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
    <webSocket enabled = "false" />
    <handlers>
      <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
      <add name = "iisnode" path = "server.js" verb = "*" modules = "iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name = "NodeInspector" patternSyntax = "ECMAScript" stopProcessing = "true">
          <match url = "^server.js/debug[/]?" />
        </rule>

        <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
        <rule name = "StaticContent">
          <action type = "Rewrite" url = "public{REQUEST_URI}"/>
        </rule>

        <!-- All other URLs are mapped to the node.js site entry point -->
        <rule name = "DynamicContent">
          <conditions>
            <add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "True"/>
          </conditions>
          <action type = "Rewrite" url = "server.js"/>
        </rule>
      </rules>
    </rewrite>

    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment = "bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse = "PassThrough" />

    <!--
      You can control how Node is hosted within IIS using the following options:
        * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
        * node_env: will be propagated to node as NODE_ENV environment variable
        * debuggingEnabled - controls whether the built-in debugger is enabled

      See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
    -->
    <!--<iisnode watchedFiles = "web.config;*.js"/>-->
  </system.webServer>
</configuration>

Глядя на это, я подумал, что эта строка:

<add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "True"/>

Будет игнорировать маршрутизацию и обслуживать физический файл, но, похоже, этого не происходит. Может ли кто-нибудь помочь мне обновить мой web.config, чтобы он всегда обслуживал /sitemap.xml, прежде чем он начнет использовать маршрутизацию Angular?

Тестирование функциональных ngrx-эффектов в Angular 16 с помощью Jest
В системе управления состояниями ngrx, совместимой с Angular 16, появились функциональные эффекты. Это здорово и делает код определенно легче для...
Angular и React для вашего проекта веб-разработки?
Angular и React для вашего проекта веб-разработки?
Когда дело доходит до веб-разработки, выбор правильного front-end фреймворка имеет решающее значение. Angular и React - два самых популярных...
Эпизод 23/17: Twitter Space о будущем Angular, Tiny Conf
Эпизод 23/17: Twitter Space о будущем Angular, Tiny Conf
Мы провели Twitter Space, обсудив несколько проблем, связанных с последними дополнениями в Angular. Также прошла Angular Tiny Conf с 25 докладами.
Угловой продивер
Угловой продивер
Оригинал этой статьи на турецком языке. ChatGPT используется только для перевода на английский язык.
Мое недавнее углубление в Angular
Мое недавнее углубление в Angular
Недавно я провел некоторое время, изучая фреймворк Angular, и я хотел поделиться своим опытом со всеми вами. Как человек, который любит глубоко...
Освоение Observables и Subjects в Rxjs:
Освоение Observables и Subjects в Rxjs:
Давайте начнем с основ и постепенно перейдем к более продвинутым концепциям в RxJS в Angular
0
0
512
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

попробуйте добавить новое правило

<rule name = "SiteMap" patternSyntax = "Wildcard" stopProcessing = "true">
   <match url = "sitemap.xml" />
   <action type = "Rewrite" url = "/sitemap.xml" appendQueryString = "false" />       
</rule>

вот полный xml файл

    <?xml version = "1.0" encoding = "utf-8"?>
<!--
     This configuration file is required if iisnode is used to run node processes behind
     IIS or IIS Express.  For more information, visit:

     https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
  <system.webServer>
    <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
    <webSocket enabled = "false" />
    <handlers>
      <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
      <add name = "iisnode" path = "server.js" verb = "*" modules = "iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name = "SiteMap" patternSyntax = "Wildcard" stopProcessing = "true">
          <match url = "sitemap.xml" />
          <action type = "Rewrite" url = "/sitemap.xml" appendQueryString = "false" />       
      </rule>

        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name = "NodeInspector" patternSyntax = "ECMAScript" stopProcessing = "true">
          <match url = "^server.js/debug[/]?" />
        </rule>

        <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
        <rule name = "StaticContent">
          <action type = "Rewrite" url = "public{REQUEST_URI}"/>
        </rule>

        <!-- All other URLs are mapped to the node.js site entry point -->
        <rule name = "DynamicContent">
          <conditions>
            <add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "True"/>
          </conditions>
          <action type = "Rewrite" url = "server.js"/>
        </rule>
      </rules>
    </rewrite>

    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment = "bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse = "PassThrough" />

    <!--
      You can control how Node is hosted within IIS using the following options:
        * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
        * node_env: will be propagated to node as NODE_ENV environment variable
        * debuggingEnabled - controls whether the built-in debugger is enabled

      See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
    -->
    <!--<iisnode watchedFiles = "web.config;*.js"/>-->
  </system.webServer>
</configuration>

Другие вопросы по теме