相关疑难解决方法(0)

当我通过浏览器刷新时出现Angular 2:404错误

我是Angular 2的新手.我已将我的单页应用程序存储在名为"myapp"的文件夹中的服务器中.我已将基础中的网址更改为http://example.com/myapp/ `.

我的项目有两页.所以我实现了Angular 2路由.我将默认页面设置为登录.当我http://example.com/myapp/在浏览器中输入时,它会自动重定向到http://example.com/myapp/login.但如果刷新该页面我会收到404错误,说http://example.com/myapp/login找不到.

但如果我使用lite服务器运行我的项目,一切正常.在这种情况下,index.html中的URL将是"/".如何解决?

angular2-routing angular

164
推荐指数
7
解决办法
16万
查看次数

在IIS上托管的Angular 2:HTTP错误404

我有一个简单的应用程序,其中一个组件需要来自url的某些参数.应用程序中只有一条路线:

const appRoutes: Routes = 
                       path: 'hero/:userId/:languageId',component: HeroWidgetComponent }];
Run Code Online (Sandbox Code Playgroud)

在Index.html中,我在标题中有这个 <base href="/">

我正在使用webpack,并且在浏览url时,应用程序在开发环境中运行良好:http://localhost:4000/hero/1/1.

但是,在构建用于生产的应用程序并获取分发文件时,请在IIS上托管该应用程序.尝试浏览同一个网址时出现以下错误:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Run Code Online (Sandbox Code Playgroud)

如果我删除所有路由并只http:localhost:4200在IIS上浏览:该应用程序工作正常.

iis http-status-code-404 angular2-routing angular

13
推荐指数
3
解决办法
1万
查看次数