Asp.net mvc4配置一个路由来实现几个网址

时间:2016-09-21 09:07:52

标签: c# asp.net asp.net-mvc asp.net-mvc-4

在我的控制器中:

public ActionResult Question(string id, int status = 1, int? page = 1, int? pageSize = 20) { //... }

RouteConfig:

routes.MapRoute(
    name: "Route_UserQuestion",
    url: "User/{action}/{id}/{status}/{page}/{pagesize}.html",
    defaults: new { controller = "User", action = "Question", status = UrlParameter.Optional, page = UrlParameter.Optional, pagesize = UrlParameter.Optional }
);

但这是错误的,我想要一个配置来实现几个网址:

/User/Question/1234.html
/User/Question/1234/2.html
/User/Question/1234/2/1.html
/User/Question/1234/2/1/20.html

谢谢!

0 个答案:

没有答案