我使用asp.net mvc3,并且我想编写没有结尾的路由。我的意思是:
www.site.com/Cameras/{id}={string}/{id}={string}/{id}={string}/{id}={string}.....其中id表示过滤器id,字符串表示该过滤器的值。我有许多类型的过滤器,在未来我希望能够添加更多的过滤器,而不需要任何依赖。这种路由应该是什么样子的?我该如何开始处理这些参数?
发布于 2012-01-03 17:52:39
你需要做的是写一个包罗万象的路由,然后这样解释它:
routes.MapRoute("Cameras", "cameras/{*url}",
new { controller = "Cameras", action = "Index" }
);
public ActionResult Index(string url)
{
var ids = url.split('/');
// now do what you need with the ids
}您应该像这样使用urls:
/cameras/id1/id2/id3/id4
https://stackoverflow.com/questions/8710312
复制相似问题