ASP.NET--MVC--伪静态
2024-09-20 00:20:08
原文地址
以前伪静态很流行主要是为了SEO优化排名,现在搜索引擎对静态网站和动态网站的权重差不多了,就没有必要再伪静态了,个人意见,仅供参考。
有些客户要求设置静态的,为了完成需求,而且更简单的做法就是设置伪静态,例如: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 }//默认配置
);
}
最新文章
- SQL Server 多条记录的某个字段拼接
- Android Canvas设置绘画时重叠部分的处理模式【含效果图】
- asp.net mvc,做 301 永久重定向
- java的位运算符
- Spring + Mybatis 项目实现动态切换数据源
- Python爬虫(二十四)_selenium案例:执行javascript脚本
- SpringCloud的服务注册中心(二)注册中心服务端和两个微服务应用客户端
- 2018-2019-2 网络对抗技术 20165308 Exp3 免杀原理与实践
- shell脚本学习-练习写一个脚本2
- GitHub 优秀的 Android 开源项目 (精品)
- Docker配置参考
- 模糊测试(fuzzing)是什么
- ";留拍";-注册/登录详解
- Understanding Flash: Blocks, Pages and Program / Erases
- 标准库 os、sys、logging、configparser、time、requests
- tkinter模块
- Linux 下解压 rar 文件
- Tensorflow 方法记录
- 关于maven工程打jar的问题
- ChemDraw 16最新版本发布 更效率科研的首选
热门文章
- 应用程序 /dev/rtc 编程 获取时间 2011-12-13 01:01:06【转】
- DMA(direct memory access)直接内存访问
- 【POJ 3635】 Full Tank
- jsp页面导入excel文件的步骤及配置
- 【SQL】INTERVAL YEAR TO MONTH 和 INTERVAL DAY TO SECOND
- 安卓手机USB无法共享、上网或卡顿的解决方法
- MatLab之Simulink之simple model
- 论 fmap、fmap fmap、与 fmap fmap fmap
- js消息框
- spring IOC bean中注入bean