开发者

RedirectToAction without querystring MVC

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜