Reputation: 6640
I need to define an MVC route for URL like this:
http://localhost/RealSuiteApps/RealHelp/-1/Detail/BRK18482020
where:
Detail - is controller name
I need this to go to DetailController, Index action with orderId parameter.
I tried this:
routes.MapRoute(
name: "Detail",
url: "Detail/{id}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index", id = UrlParameter.Optional }
);
but I get a message "Page Not Found". What am I missing here ??
Upvotes: 1
Views: 379
Reputation: 247018
Assuming DetailController action
public ActionResult Index(int clientId, string orderId) { ... }
Then route would be mapped as
routes.MapRoute(
name: "Detail",
url: "{cientId}/Detail/{orderId}",
defaults: new { clientid = "-1", controller = "Detail", action = "Index" }
);
Note that this should also be registered before any default routes.
Upvotes: 1