MVC4设置伪静态---路由伪静态
有些客户要求设置静态的,为了完成需求,而且更简单的做法就是设置伪静态,例如:http://localhost:80/Home/Index.html ,也可以访问http://localhost:80/Home/Index 这是比较简单省力的一个办法,如果每个页面都是生成一个静态,访问速度是提高了,可代码量就增加,我们就可以利用mvc4的路由设置伪静态。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Action1Html", // action伪静态
"{controller}/{action}.html",// 带有参数的 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(
"ActionHtml", // action伪静态
"{controller}/{action}.html/{id}",// 带有参数的 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 }//默认配置
);
}
MVC4设置伪静态---路由伪静态的更多相关文章
- asp.net mvc 伪静态路由配置
asp.net mvc实现伪静态路由必须按如下方式设置好,才能访问 .htm 或者.html页面 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspne ...
- ASP.NET MVC4通过UrlRewriter配置伪静态,支持html后缀
参考文章: ASP.NET MVC4通过UrlRewriter配置伪静态 http://blog.csdn.net/just_shunjian/article/details/51132866 .NE ...
- MVC 伪静态路由、MVC路由配置,实现伪静态。
前段时间,研究了一下mvc路由配置伪静态,在网上扒了很多最后还是行不通,所以我现在把这些心得整理出来,供大家分享: 1.mvc中默认路由配置是:http://localhost:24409/Home/ ...
- tp路由+伪静态+去掉index.php
浏览:10536 发布日期:2013/10/08 分类:技术分享 关键字: 路由 伪静态 去掉index.php 之前一个网友说能不能达到这样的效果,www.olcms.com/news/id.htm ...
- mvc 路由伪静态实现
很多网站都采用伪静态,例如以html.shtml等结尾的url,mvc的路由可以轻松实现. 配置路由 默认路由配置 添加伪静态路由 mvc的路由原理是从上往下匹配的,所以只需要在后面添加自己配置的路由 ...
- Azure Application Gateway (3) 设置URL路由
<Windows Azure Platform 系列文章目录> 在之前的文章中,笔者介绍了Azure Web App可以设置URL路由.如下图: 在这里笔者简单介绍一下,首先我们还是创建以 ...
- Azure Application Gateway (4) 设置URL路由 - PowerShell
<Windows Azure Platform 系列文章目录> 本文将介绍如果使用Azure PowerShell,创建Azure Application Gateway URL Rout ...
- asp.net mvc4设置area里面使用相同的 Controller 名称并设置area里的页面为起始页
asp.net mvc4设置area里面使用相同的 Controller 名称并设置area里的页面为起始页 1.使用重名controller 在asp.net mvc2以后的版本里面,有了area( ...
- 设置Mvc路由Asp.net 与 mvc同用
App_start/RouteConfig.cs/RegisterRoutes(RouteConllection routes) { routes.IgnoreRoute("{resourc ...
随机推荐
- FastDFS介绍和配置过程 二
最近在研究负载均衡和集群,其中涉及到一个主要问题是,如何让集群中的real server共享一套文件系统.在网上查到FastDFS,国人(happy fish,感谢他的开源精神)开发的一套轻量级分 ...
- ubuntu 14 编译ARM g2o-20160424
1. 安装eigen sudo apt-get install libeigen3-dev sudo apt-get install libsuitesparse-dev sudo apt-get i ...
- CountDownLatch、信号量
countDownlatch可以阻塞线程,可以在某种条件下继续执行 不安全的:
- 特征选择Boruta
A good feature subset is one that: contains features highly correlated with (predictive of) the clas ...
- Flask解决跨域
Flask解决跨域 问题:网页上(client)有一个ajax请求,Flask sever是直接返回 jsonify. 然后ajax就报错:No 'Access-Control-Allow-Origi ...
- 【linux命令】setterm控制终端属性命令(中英文)
[linux命令]setterm控制终端属性命令(中英文) 2018年03月23日 17:13:44 阅读数:489 标签: linux 更多 个人分类: linux 摘自:https://blog. ...
- Part6-点亮指路灯_lesson1
1. 2.GPIO 查阅芯片手册:GPIO 代码: 3.外设基地址初始化 打开arm核手册, 基地址为0x70000000,去搜芯片手册6410, 把这个基地址告诉处理器,通过协处理器的cp15, 转 ...
- HandleErrorAttribute只能处理httpStatusCode为500的异常(服务器异常)
HandleErrorAttribute源代码: [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited ...
- Ubuntu普通用户使用串口设备
将普通用户加入dialout组,然后重启或注销登录 sudo gpasswd --add username dialout
- hibernate的获取session的两方法比较,和通过id获取对象的比较,一级缓存二级缓存
opensession与currentsession的联系与区别 在同一个线程中opensession的session是不一样的,而currentsession获取的session是一样的,这就保证了 ...