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=th开发者_开发知识库e-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.
精彩评论