我正在使用Windows Server 2012 R2的IIS中托管的angular 7 Web应用程序。 这是在ASP.NET CORE 2.2上。
当我使用域名导航应用程序时,它可以正常工作,但是如果刷新我访问过的页面,则它会给我“ 您要查找的资源已被删除,名称已更改或暂时被删除。无法使用。”
如果我用chrome检查开发人员工具,它会显示以下错误。请参考下图:
此 user-type-selection:1 是路由路径和参数值。
我试图在 ClientApp 的 src 文件夹中添加 web.config ,并将其作为角的资产。 json 。它将web.config添加到发布文件夹中,但为此,我收到 500个内部服务器错误。
有人对此有任何想法吗?
答案 0 :(得分:0)
此问题已通过web.config中的以下内容解决:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<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=”/my-app/” /> -->
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
请使用户URL Rewrite extension安装在IIS中。
我之前尝试过上面的web.config,但没有上面的扩展名,因此它给了我500错误。
快乐的编码。