【发布时间】:2018-01-16 03:41:05
【问题描述】:
我在 IIS 中托管了我的 angular2 应用程序,当我浏览应用程序时它正在正确加载,当我刷新页面时它显示 404 错误。为了解决这个问题,我点击了这些链接
2) http://jasonwatmore.com/post/2017/02/24/angular-2-refresh-without-404-in-node-iis
我通过参考以上两个链接创建了以下规则
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="LogViwerRouting">
<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>
如果我刷新页面,它应该加载相同的页面,所有更改都将被还原,但它没有按预期工作。谁能帮我解决这个问题?
【问题讨论】:
-
是纯 UI 还是你的代码中也有 MVC,其背后有第一个路由路由
-
@RRForUI:纯UI,代码中没有MVC。我使用 URL Rewriter 在 IIS 中创建了规则,它创建了我在问题中提到的 web.config 文件。
标签: angular iis url-rewriting