Asp.net mvc 配置伪静态方法
1.安装UrlRewriter
2.
<system.webServer> 这个节点下面添加配置
<modules runAllManagedModulesForAllRequests="true" />
3.配置RouteConfig
具体配置如下:
routes.MapRoute(
"Action1Html", // action伪静态
"{controller}/{action}.html",// 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }// 参数默认值
);
routes.MapRoute(
"ActionHtml", // action伪静态
"{controller}/{action}.html/{id}",// 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }// 参数默认值
);
routes.MapRoute(
"IDHtml", // id伪静态
"{controller}/{action}/{id}.html",// 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }// 参数默认值
);
routes.MapRoute(
"ControllerHtml", // controller伪静态
"{controller}.html/{action}/{id}",// 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }// 参数默认值
);
routes.MapRoute(
"Root",
"",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });//根目录匹配
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
相关文章
- 【Linux】线程实例 | 简单线程池
- django——ORM常用查询总结
- windows C盘实际可见文件的大小远小于C盘显示的已用容量
- 初步了解多线程概念
- 并查集(不相交集)详解
- 【课程设计】教务信息管理系统
- C#带命令行参数调用外部程序
- [翻译]《Programming - Principles and Practice Using C++, Second Edition》- Chapter 1
- 博客系统(界面设计)
- python IDLE的简明图示使用说明(适合初学者)
- 【C#】: Import “google/protobuf/timestamp.proto“ was not found or had errors.问题彻底被解决!
- 【JavaEE】浅识进程
- 详解自定义钉钉机器人推送消息(一) PHP篇
- TCP三次握手与四次挥手(一次明白)
- 系统盘空间不够,手动清理C盘的一些思路(欢迎讨论)
- ERROR Plugin load failed: hexo-admin Error: EISDIR: illegal operation on a directory, read
- linux 基础
- Qt 单例模式第一次尝试
- 第03节 VS2019 窗口布局介绍
- Spring更简单的使用方法