小编Sso*_*ncy的帖子

Asp.net MVC 5 MapRoute的多个路由

我在RouteConfig中有3条路由:

routes.MapRoute(
    name: "ByGroupName",
    url: "catalog/{categoryname}/{groupname}",
    defaults: new { controller = "Catalog", action = "Catalog" }
);
routes.MapRoute(
    name: "ByCatName",
    url: "catalog/{categoryname}",
    defaults: new { controller = "Catalog", action = "Catalog" }
);
routes.MapRoute(
    name: "ByBrandId",
    url: "catalog/brand/{brandId}",
    defaults: new { controller = "Catalog", action = "Catalog" }
);
Run Code Online (Sandbox Code Playgroud)

这是我的动作控制器接收参数:

public ActionResult Catalog(
    string categoryName = null,
    string groupName = null,
    int pageNumber = 1,
    int orderBy = 5,
    int pageSize = 20,
    int brandId = 0,
    bool bundle = …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-mvc-routing maproute asp.net-mvc-5

3
推荐指数
1
解决办法
1万
查看次数