此 URL 的 MVC 路由应该是什么?
What should be an MVC route for this URL?
我需要像这样为 URL 定义 MVC 路由:
http://localhost/RealSuiteApps/RealHelp/-1/Detail/BRK18482020
其中:
详细信息 - 是控制器名称
- 应执行默认操作索引
- -1 是一些客户端 ID
- BRK18482020 是 orderId
我需要这个来转到 DetailController,带有 orderId 参数的索引操作。
我试过这个:
routes.MapRoute(
name: "Detail",
url: "Detail/{id}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index", id = UrlParameter.Optional }
);
但我收到一条消息 "Page Not Found"。 我在这里错过了什么??
假设 DetailController 动作
public ActionResult Index(int clientId, string orderId) { ... }
那么路由会被映射为
routes.MapRoute(
name: "Detail",
url: "{cientId}/Detail/{orderId}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index" }
);
请注意,这也应该在任何默认路由之前注册。
我需要像这样为 URL 定义 MVC 路由:
http://localhost/RealSuiteApps/RealHelp/-1/Detail/BRK18482020
其中:
详细信息 - 是控制器名称
- 应执行默认操作索引
- -1 是一些客户端 ID
- BRK18482020 是 orderId
我需要这个来转到 DetailController,带有 orderId 参数的索引操作。
我试过这个:
routes.MapRoute(
name: "Detail",
url: "Detail/{id}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index", id = UrlParameter.Optional }
);
但我收到一条消息 "Page Not Found"。 我在这里错过了什么??
假设 DetailController 动作
public ActionResult Index(int clientId, string orderId) { ... }
那么路由会被映射为
routes.MapRoute(
name: "Detail",
url: "{cientId}/Detail/{orderId}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index" }
);
请注意,这也应该在任何默认路由之前注册。