MVC2 如何实现伪静态 .html
公司是开发门户网站的,为了SEO的优化工作,项目是使用MVC2开发的,现在访问页面需要将路径给我.html的样子。怎么实现?
[解决办法]
routes.MapRoute(
"Default", // 路由名称
"{controller}/{action}.html", // 带有参数的 URL
new { controller = "Home", action = "Index" } // 参数默认值
);
MVC路由
[解决办法]
请搜索“MVC路由”
这个在路由里面配置就可以了
Global这个文件中
不过还需要html么?一样收录吧
[解决办法]
routes.MapRoute("NoAction", "{controller}.html", new { controller = "home", action = "index", id = "" });//无Action的匹配 routes.MapRoute("NoID", "{controller}/{action}.html", new { controller = "home", action = "index", id = "" });//无ID的匹配 routes.MapRoute("Default", "{controller}/{action}/{id}.html", new { controller = "home", action = "index", id = "" });//默认匹配 routes.MapRoute("Root", "", new { controller = "home", action = "index", id = "" });//根目录匹配
[解决办法]
没加过当然404