MVC如何在路由器(RouteConfig)定义后缀.html
2024-10-19 13:34:56
一.配置文件web.config添加一下设置
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
二.RouteConfig.cs设置
routes.MapRoute(
"Login",
"Login.html",
new { controller = "Home", action = "Login" }
); routes.MapRoute(
"Index",
"index.html",
new { controller = "Home", action = "Index" }
); routes.MapRoute(
"Default",
"{controller}/{action}.html",
new { controller = "Home", action = "Index"}
);
三.上面设置好后基本上已经完成了,但是运行时发现首页不对,这个时候需要一下设置
在Global.asax文件里设置首页
//把首页设置为重定向后的index.html地址
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/") Context.RewritePath("index.html");
}
最新文章
- 整理: Android HAL
- 跟我一起学WCF(5)——深入解析服务契约[上篇]
- Careercup - Google面试题 - 6332750214725632
- 【Valid Parentheses】cpp
- ubuntu下Rhythmbox播放器乱码问题解决方案
- 解决ashx文件下的Session“未将对象引用设置到对象的实例”
- 零基础学Python 3之环境准备
- Eclipse的修改编码插件使用
- sourceTree安装与使用
- iostat中 %util高 应用延迟高
- css reset的重置作用(可取还是不可取,取决于你)
- 《jmeter:菜鸟入门到进阶》系列
- Django 之 cookie和session
- 1.编写一个shell脚本
- 面向对象【林老师版】:__init__定制自己独有的特征(三)
- 【Java】-NO.16.EBook.4.Java.1.003-【疯狂Java讲义第3版 李刚】- oop
- 四则运算level2
- 【Centos】centos查看磁盘使用情况
- vulcanjs 包类型
- RAC转换传统的通信
热门文章
- CSAcademy Palindromic Concatenation 字符串哈希
- 《Cracking the Coding Interview》——第16章:线程与锁——题目3
- USACO Section1.2 Transformations 解题报告
- Oracle 学习----:Oracle删除表时报错:表或视图不存在
- 孤荷凌寒自学python第三十八天初识python的线程控制
- python中的re模块,常用函数介绍
- GCC特性之__init修饰解析 - kasalyn的专栏 - 博客频道 - CSDN.NET
- Java性能监控之Java程序执行解析
- FreeBSD NTP 简单使用
- AtCoder keyence2019 E Connecting Cities