RedirectToAction没有查询字符串MVC [英] RedirectToAction without querystring MVC
本文介绍了RedirectToAction没有查询字符串MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一点code在这里,我执行重定向MVC应用程序。
I have a bit of code here in my mvc app that performs a redirect.
return RedirectToAction("Details", new { slug = viewModel.Farm.Slug });
这重定向到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?
推荐答案
定义在Global.asax中的路由匹配的路由表上面。
Define a route matching to the above in the Routes Table in your global.asax.
这篇关于RedirectToAction没有查询字符串MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文