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 ...
随机推荐
- sass进阶—变量运算
/*变量操作 (两个变量之间的运算符需要用空格隔开,否则会报错.)==,!= <,>,<=,>=+,-,*,/,% */ $width1:50px;$width2:100px; ...
- sql server 中getdate() 的日期时间字符串表示法
1. SELECT CONVERT(varchar(100), GETDATE(), 0) 05 9 2011 9:12AM SELECT CONVERT(varchar(100), GETDATE( ...
- Ethereum(1)—— 基本介绍
1 环境安装 安装Ethereum 协议的Go语言的最新实现. git clone https://github.com/ethereum/go-ethereum.git make all cd bu ...
- Codeforces 1109E. Sasha and a Very Easy Test 线段树
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1109E.html 题意 给定一个长度为 n 的数列 a,以及一个模数 M(不一定是质数). 要求支持 q ...
- swift中Cell的内容定制
1.cellForTitle 2.register
- (74)Wangdao.com第十三天_Object 对象_属性描述对象
Object 对象 JavaScript 原生提供 Object 对象 JavaScript 的所有其他对象都继承自 Object 对象,即那些对象都是Object的实例 Object 对象的原生方 ...
- __http原理__01__通信流程_消息格式
本文转自 菜鸟教程 一.HTTP协议(HyperText Transfer Protocol,超文本传输协议) 是因特网上应用最为广泛的一种网络传输协议, 是用于从万维网(WWW:World Wi ...
- 19 ArcGIS Server 备份与恢复
一.备份过程 1.找到已经安装的arcgis server安装目录,并找到备份工具: 2.快捷键win + R启动cmd,将备份工具文件拖入cmd窗口,enter 3. 通过backup.py脚本进行 ...
- swust oj 237
Calculate Sum-Of-Absolute-Differences 1000(ms) 65535(kb) 131 / 683 给你N个正整数,求两两之差的绝对值之和. 比如有4个数分别为 3, ...
- XAMPP 安装时 MySQL 无法启动,且提示端口占用。
今天安装XAMPP时遇到了几个坑,忙活了一上午才搞定,写下来分享给同样遇坑的盆友们. MySQL 点击start 提示端口3306被占用,我改了端口号,又改了注册表,将注册表地址改为xampp中mys ...