Angular 2 路由引发 404 错误 [英] Angular 2 routing raising 404 errors

查看:42
本文介绍了Angular 2 路由引发 404 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5 PushState 表示当我使用 'npm start' 命令运行我的 Angular 应用程序时,刷新 URL 或在浏览器中输入直接 URL 工作得很好从 VS 2015 命令提示符.但是,当我在 IIS 上部署相同的应用程序并将 <base href="/"/> 更改为 <base href="/MyVirtualApplication/"/> 然后HTML5 的 PushStateHistory API 无法正常工作并引发 404 错误.

HTML5 PushState means refresh URL or enter direct URL in browser works perfectly fine when I run my angular app using 'npm start' command from VS 2015 command prompt. However when I deploy same application on IIS and change <base href="/"/> to <base href="/MyVirtualApplication/" /> then HTML5's PushState or History API doesn't work properly and raising 404 error.

请提出建议.

推荐答案

我想我是在对 nodejs 有基本了解并在 Angular2 中使用它之后得到了答案.

I Think I got my answer after basic understanding on nodejs and use of it with Angular2.

基本上,nodejs - expressjs 本身是一个 web 服务器,当我们执行命令 npm start web server 启动并在定义的端口上列出.它不需要任何额外的服务器.

Basically, nodejs - expressjs itself is a web server and when we execute a command npm start web server starts and listing on a port which is defined. And it does not require any additional server.

这篇关于Angular 2 路由引发 404 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆