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?
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With