Aran Mulholland
Aran Mulholland

Reputation: 23935

ASP.NET Routing a URL that does not contain a controller name

I would like to direct the following URL:

http://myweburl/Wheel/466/Direction/903/Highlight/7

To a controller action:

public ActionResult Index(int wheel, int direction, int highlight)

On the controller VehicleController I still want to keep my Home/Index as the root url of the site. So if someone entered

http://myweburl/

They would be directed to Home/Index How do I do this?

Upvotes: 1

Views: 105

Answers (1)

Aran Mulholland
Aran Mulholland

Reputation: 23935

Just add the follwing as a route above the default route (Home/Index)

routes.MapRoute(
    name: "WheelRoute",
    url: "Wheel/{wheel}/Direction/{direction}/Highlight/{highlight}",
    defaults: new { controller = "VehicleController", action = "Index" }
 );

Upvotes: 2

Related Questions