I have a controller called CarController located in a folder called Buy. So the url becomes www.website.com/Buy/Car
How do I make the url be instead "/purchase/vehicle" without changing controller and folder name?
Thanks!
You can do this with a custom route. See here for informations about routing. You can then create your custom route with default values for the Controller and the action, something like:
routes.MapRoute(
"MyRoute",
"purchase/vehicle",
defaults: new { controller = "Car", action = "Buy" }
);
You have to put in there the correct controller name and the action you want to call.
routes.MapRoute("buyCar", "purchase/vehicle", new { controller = "Car", action = "Buy" });