且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Asp.net 4.5进行Angular2路由

更新时间:2023-02-15 20:14:47

您可以将所有内容重定向到index.html页面以解决此问题,这是我在一个项目中使用的配置代码:

You could redirect everything to the index.html page to solve this issue, here's the configuration code I used in one of my project:

<rewrite>
  <rules>
    <rule name="RedirectEverything" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/api/" negate="true" />
      </conditions>
      <action type="Rewrite" url="/index.html" />
    </rule>
  </rules>
</rewrite>

在web.config的system.websever部分下添加此

Add this under the the system.websever section in your web.config