I have a bit of code here in my mvc app that performs a redirect.
return RedirectToAction("Details", new { slug = viewModel.Farm.Slug });
This redirect to the url
/Farm/Details?slug=the-farm-name
What i'd like it to do is this
/Farm/Details/the-farm-name
Is there a simple way to do this?
Define a route matching to the above in the Routes Table in your global.asax.
you are using default routing, where you have defined one parameter "id". Change your code to return
RedirectToAction("Details", new {id = viewModel.Farm.Slug })
;
or add new 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