日期:2014-05-16  浏览次数:20517 次

mvc4.0怎么做伪静态
如题mvc4.0怎么做伪静态   以下是路由: routes.MapRoute(
                name: "Default",  // 路由名称
                url: "{controller}/{action}/{id}", // 带有参数的 URL
                defaults: new { controller = "WebDefault", action = "Index", id = UrlParameter.Optional } // 参数默认值
            );
要把http://www.kulengidc.com/help/Article/ShowContent?ID=256  伪静态成http://www.kulengidc.com/help/Article/256.html
------解决方案--------------------
url: "{controller}/{action}/{id}.html", // 带有参数的 URL
------解决方案--------------------
你多研究下路由,url: "{controller}/{action}/{id}.html", // 带有参数的 URL ,这个方法是绝对正确的。
 ArticleID = Convert.ToInt32(Request.QueryString["ID"]);   MVC里面提取路由参数是这样的嘛?
------解决方案--------------------
路由心成
{controller}/{action}/{id}.html

action方法
public ActionResult ShowContent(int id)
{
...
}
------解决方案--------------------
你的Action都没有参数,肯定匹配不了。id参数需要你在Action中体现出来。
------解决方案--------------------
在Global中,编写路由。