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

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

问题描述

HTML5 PushState 表示刷新URL或在浏览器中输入直接URL 效果很好,当我使用VS 2015命令提示符下的'npm start'命令运行我的角度应用程序时.但是,当我在IIS上部署相同的应用程序并将<base href="/"/>更改为<base href="/MyVirtualApplication/" />时,则 HTML5的PushState 历史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服务器将启动并在已定义的端口上列出.而且它不需要任何其他服务器.

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天全站免登陆