1

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?

2
  • I've a suggestion for you. The parameters wheel, direction and highlight are different from each other. direction is not a category of wheel and highlight is not a category of direction. You could separate those items by '/' if those items have a relationship like category/item. I would suggest you to pass those values as querystrings instead of route parameters and by that way you are more RESTful. Commented Nov 12, 2012 at 9:24
  • @Mark thanks for the suggestion but this is just a contrived example, in my production code the parameters are related. (should of thought a bit more before posting) Commented Nov 12, 2012 at 22:33

1 Answer 1

2

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" }
 );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.