【发布时间】:2013-04-14 21:44:33
【问题描述】:
这是我的操作链接
@Html.ActionLink(item1.TranslatedName,"Index","Properties",new { CategoryId=item1.CategoryId,CategoryName=item.CategoryName},null)
当前生成的url是
http://abc.com/Properties/?CategoryId=1&CategoryName=Banken
它也不会调用控制器的索引视图。如果我手动将 url 更改为
http://abc.com/Properties/Index?CategoryId=1&CategoryName=Banken
它的工作原理
我为此定义的路线是
routes.MapRoute(
"Properties", // Route name
"{controller}/{action}/{CategoryId}/{CategoryName}", // URL with parameters
new { controller = "Properties", action = "Index" }, // Parameter defaults
new { CategoryId = @"\d+", CategoryName = @"\d+" }
);
谁能告诉我我做错了什么?
我需要显示的网址是 http://abc.com/Properties/Banken 基本上我想隐藏类别ID并显示类别名称
【问题讨论】:
-
1.此路由是否在默认路由之前定义? (针对问题1) 2. 您不能隐藏中间(不是最后一个)路线段。
标签: asp.net-mvc asp.net-mvc-4 url-rewriting