【发布时间】:2017-10-02 19:30:41
【问题描述】:
我有一个简单的应用程序,其中一个组件需要来自 url 的某些参数。应用程序中只有一个路由:
const appRoutes: Routes =
path: 'hero/:userId/:languageId',component: HeroWidgetComponent }];
在 Index.html 中,我在标题 <base href="/"> 中有这个
我正在使用 webpack,应用程序在开发环境中运行良好,浏览 url 时:http://localhost:4000/hero/1/1。
但是,在为生产构建应用程序并获取分发文件时,然后将其托管在 IIS 上。尝试浏览相同的 url 时出现以下错误:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
如果我删除所有路由并仅在 IIS 上浏览:http:localhost:4200,应用程序工作正常。
【问题讨论】:
-
您的
IIS服务器需要正确配置,以便所有角度路由都重定向到index.html(或触发角度应用程序的html 文件)。不幸的是,我不是IIS服务器专家,所以我不能给你一个真正的答案,如何做到这一点。
标签: angular iis http-status-code-404 angular2-routing