asp.net MVC和RESTful路由,导轨式。可能吗? [英] asp.net MVC and RESTful routing, rails-style. Is it possible?
本文介绍了asp.net MVC和RESTful路由,导轨式。可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有什么办法让真正的宁静路由在MVC工作,就像铁轨帅哥有哪些?我在谈论嵌套的网址,比如 /乐队/ METALLICA /专辑/ killemall /音轨/ 4
Is there any way to get truly restful routing working in MVC, just like the rails dudes have? I 'm talking about nested urls like /bands/metallica/albums/killemall/track/4
这是我发现有用的是史蒂夫Hodgkiss'的唯一库的宁静的路由。看来虽然有点冒险立足我的整个项目对这个家伙的宠物项目的路由。
The only library that I found to be useful is Steve Hodgkiss' Restful routing. It seems though a bit risky to base my whole project's routing on this guy's pet-project.
你说呢MVC老兵?
推荐答案
当然:
routes.MapRoute("IwannaBeLikeTheCoolRailsKids",
"bands/{bandName}/albums/{albumName}/tracks/{trackNumber}",
new { controller = "Bands",
action = "ByTrack"
});
然后在你的控制器:
Then in your controller:
public ActionResult ByTrack(string bandName, string albumName, int trackNumber)
易peasie。
Easy peasie.
这篇关于asp.net MVC和RESTful路由,导轨式。可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文