如何处理mvc中的路由?

时间:2014-08-11 07:06:10

标签: c#-4.0

如何使用MVC中的“路由”隐藏控制器名称,操作名称和仅显示传递的参数 例如 网址为http://www.test.com/pages/Pages/?pageURL=Returns

我只想要网址: - http://www.test.com/Returns

pageURL =返回是动态参数值

谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个:

private void RegisterRoutes(RouteCollection routes) {

  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

  routes.MapRoute("default", "{controller}/{action}/{id}",
     new { action = "index", id = "" },
     // Register below the name of all the other controllers
     new { controller = @"^(account|support)$" });

  routes.MapRoute("home", "{action}",
     new { controller = "device", action = "index" });
}

来源:How do I configure ASP.NET MVC routing to hide the controller name on a "home" page?