Reputation: 17498
I have the following route
routes.MapRoute("CreateBook", "{controller}/{action}/{slug}/{name}", new { controller = "CreateBook", action = "Index" , slug = UrlParameter.Optional, name = UrlParameter.Optional});
For some reason, whenever I call RedirectToAction, the URL appears as
return RedirectToAction("Parameters", new { slug=1234, name="helloworld" });
http://localhost/CreateBook/Parameters?slug=1234?name=helloworld
What I would like is
http://localhost/CreateBook/Parameters/1234/helloworld
How do I achieve this?
Upvotes: 3
Views: 1796
Reputation: 73102
My guess is that the RedirectToAction
call is picking up the default route, not your specialised route.
By default, when you pass in route values, MVC will append the values as querystring parameters.
Did you put that route before the default route?
Upvotes: 3