ASP.NET MVC层次的URL路径选择 [英] ASP.NET MVC Hierarchy Url Routing
问题描述
我有一个问题
我的路线有层次的类别后,一个额外的paramater。
My route have an extra paramater after hierarchical category.
/ 2009 /世界/亚洲/ 08/12 /喇嘛喇嘛喇嘛
/2009/World/Asia/08/12/bla-bla-bla
asp.net mvc的不支持这一点,因为我的路由应该是
asp.net mvc does not support this because my routing should be
{一年} / {*类} / {月} / {天} / {name}的
{year}/{*category}/{month}/{day}/{name}
我试图用约束像
year = @"(\d{4})",category = @"((.+)/)+", month = @"(\d{2})", day = @"(\d{2})"
但我无法找到任何解决方案。
but i cannot find any solution.
有什么评论?
感谢您
推荐答案
我是pretty确保路由处理的斜杠tokenizes所以你将不能够有一个类别,其中包括一个斜杠 - - 虽然逃脱它可能工作,不知道这一点。您可能需要格式化您的网址为:
I'm pretty sure that the route handler tokenizes on the slash character so you won't be able to have a category that includes a slash -- though escaping it might work, not sure about that. You might want to format your URL as:
/2009/World+Asia/08/12/bla-bla-bla
这应该类别翻译为世亚。
This should translate the category as "World Asia".
如果不工作,那么也许你需要一台子类别以及匹配的另一条途径。
If that doesn't work then perhaps you need another route that matches on subcategory as well.
{year}/{category}/{subcategory}/{month}/{day}/{name}
这篇关于ASP.NET MVC层次的URL路径选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!