如何修复在Angular中打开新选项卡时出现的404 Not Found错误
我使用“Window.open()”在Angular中打开新选项卡 我的代码是:如何修复在Angular中打开新选项卡时出现的404 Not Found错误,angular,Angular,我使用“Window.open()”在Angular中打开新选项卡 我的代码是: let windowRef: Window = window.open('inspection/' + sheetId + '/' + equipmentId, '_blank'); 它在我本地的机器上运行得很好。但是,当我使用IIS时,它不起作用。 打开新选项卡时,将显示: HTTP错误404.0-找不到 您正在查找的资源已被删除、名称已更改或暂时不可用 有关错误的详细信息: Detailed Error In
let windowRef: Window = window.open('inspection/' + sheetId + '/' + equipmentId, '_blank');
它在我本地的机器上运行得很好。但是,当我使用IIS时,它不起作用。
打开新选项卡时,将显示:
HTTP错误404.0-找不到
您正在查找的资源已被删除、名称已更改或暂时不可用
有关错误的详细信息:
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://www.testinspection.com:80/inspection/2/GBRX700775
Physical Path C:\inetpub\wwwroot\Inspection\inspection\2\GBRX700775
Logon Method Anonymous
Logon User Anonymous
这是我的路线代码:
{
path: 'inspection/:sheetId/:carId', component: InspectionTabComponent, resolve: { inspectionData: InspectionResolve },
canActivate: [AuthGuard], canDeactivate: [CanDeactiveGuard]
},
我怎样才能修好它?
这个节目我错过了什么?
请帮助我,我提前感谢您。如果您的本地计算机工作正常,这肯定是
IIS
配置。
您应该使用此配置入站规则
希望它能帮助您:)这就是它的工作原理: 你可以打开mysite.com/。静态服务器返回index.html,该html包含指向脚本的链接,其中包含应用程序所需的所有逻辑 现在,让我们尝试导航到mysite.com/preview/大多数服务器都会尝试查看 对于/preview.html或/preview/index.html或idk。。。没有这样的页面。这就是为什么你需要重写这个请求并返回原始的/index.html,它包含了你的应用所需要的一切。/preview导航将在客户端javascript内部处理,即angular库内部 配置可能看起来像来自的配置
<rewrite>
<rules>
<rule name="SPA Routes" stopProcessing="true">
<!-- match everything by default -->
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<!-- unless its a file -->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<!-- or a directory -->
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<!-- or is under the /api directory -->
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<!-- list other routes or route prefixes here if you need to handle them server side -->
</conditions>
<!-- rewrite it to /index.html -->
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>