angular当router使用userhash:false时路由404问题
angular当router使用userhash:false时路由404问题
安装iis urlrewrite2.0组件
在根目录下创建 Web.config
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
.netcore 中间件方法
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html";
context.Response.StatusCode = 200;
await next();
}
});
纯angular项目可以移除其它的默认首页
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("/index.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
angular当router使用userhash:false时路由404问题的更多相关文章
- [Angular 2 Router] Configure Your First Angular 2 Route
Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...
- react router 4.0以上的路由应用
thead>tr>th{padding:8px;line-height:1.4285714;border-top:1px solid #ddd}.table>thead>tr& ...
- 10. vue axios 请求未完成时路由跳转报错问题
axios 请求未完成时路由跳转报错问题 前两天项目基本功能算是完成了,在公司测试时遇到了遇到了一个问题,那就是在请求未完成时进行路由跳转时会报错,想了几种办法来解决,例如加loading,请求拦截, ...
- layui table分页 page为false时,limit问题
问题描述:table数据表格page设为false时,limit为默认设置10 解决办法:limit设为 Number.MAX_VALUE 加载全部数据 实例: var table = layui.t ...
- easyui-combobox的option选项为true与false时的问题
如题,我们使用easyui-combobox,当我们的选择项为true与false时,即选择是否,后台返回一个boolean类型的变量,那么这时候,通过form表单进行反显会出现这样的问题:表单里ea ...
- Jdbc Url 设置allowMultiQueries为true和false时底层处理机制研究
一个mysql jdbc待解之谜 关于jdbc url参数 allowMultiQueries 如下的一个普通JDBC示例: String user ="root"; Strin ...
- jQuery ajax 当async为false时解决同步操作失败的问题
jQuery的ajax,当async为false时,同步操作失败.解决方案,jqueryasync 最近做项目遇到jQuery的ajax,当async为false时,同步操作失败的问题,上网搜索下,得 ...
- [Angular2 Router] Configure Auxiliary Routes in the Angular 2 Router - What is the Difference Towards a Primary Route?
In this tutorial we are going to learn how we can can configure redirects in the angular 2 router co ...
- 当Django设置DEBUG为False时,发现admin和html的静态资源文件加载失败的解决办法
当Django设置DEBUG为False时,发现admin和html的静态资源文件加载失败,折腾一段时间终于找到解决办法: 1.先在setting文件增加BASE_DIR(项目的路径) BASE_DI ...
随机推荐
- vue 3.0
参照网址: https://blog.csdn.net/qq_36407748/article/details/80739787
- python设计模式---结构型之门面模式
门面,系统,客户端~ from django.test import TestCase class Hotelier: def __init__(self): print('Arranging the ...
- UOJ#201. 【CTSC2016】单调上升路径 构造
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ201.html 题解 首先把题目里面的提示抄过来: 结论:假设带权无向图 G 有 100 个节点 1000 ...
- 解决'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
懒癌晚期,直接贴图 然后就解决了!
- SpringBoot使用Nacos服务发现
本文介绍SpringBoot应用使用Nacos服务发现. 上一篇文章介绍了SpringBoot使用Nacos做配置中心,本文介绍SpringBoot使用Nacos做服务发现. 1.Eureka闭源 相 ...
- FLASK 的Session和MoudelForm插件
falsk是小而精的框架,但是热度高, 所有很多爱好者提供了很多扩展插件 功能强大,美而不足的就是兼容稳定性有时候不太好,不过大部分还是很可以的 Flask-Session flask内置sessio ...
- C语言面对对象设计模式汇编
面向对象发展到今天,已经出现了许许多多优秀的实践.方法和技术.很多的技术都能够有效的提高软件质量.IBM上的<面向对象软件开发和过程>系列文章对面对对象设计从如下层面进行了详细的介绍:代码 ...
- python文本读写数据
# 写方法1 f = open('tmp.txt','w') f.write('hello world') f.close() # 写方法2 with open('tmp.txt','w') as f ...
- VIM编辑器用法
Vim (vim + filename有则进入文件,无则创建并进入文件)>进入编辑模式,包括命令模式.插入模式.末行模式,具体命令: 按esc进入命令模式 按'shift' + ':'进入末行模 ...
- MongoDB_简介_安装_基本使用_js_mongoose 操作 MongoDB 编程
数据库 按照数据结构来组织.存储和管理数据的仓库 程序运行时,数据存储于内存中,一旦程序结束或者断电,就会数据丢失 为了将有些数据持久化存储到硬盘中,并确保可操作性和安全性,就需要数据库 分类: 关系 ...