asp.net MVC3 RouteLink [英] asp.net mvc3 RouteLink
本文介绍了asp.net MVC3 RouteLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚升级我的MVC2应用MVC3。而routelink停止工作。任何线索??
全球
routes.MapRoute(
类别,
类别/ {猫} / {SUBCAT} / {PAGE} / {} viewall
新
{
控制器=类别,
行动=索引,
猫= UrlParameter.Optional,
SUBCAT = UrlParameter.Optional,
页= UrlParameter.Optional,
viewall = UrlParameter.Optional
}
);
查看
<%:Html.RouteLink(妇女,类别,新{猫=女,SUBCAT =})%GT;
这是它如何呈现
< A HREF =>妇女< / A>
解决方案
这是一个回归的错误,如菲尔哈克[<一个解释href=\"http://haacked.com/archive/2011/02/20/routing-regression-with-two-consecutive-optional-url-parameters.aspx\" rel=\"nofollow\">http://haacked.com/archive/2011/02/20/routing-regression-with-two-consecutive-optional-url-parameters.aspx ]
I have just upgraded my mvc2 app to mvc3. And the routelink stopped working. any clue??
Global
routes.MapRoute(
"Category",
"category/{cat}/{subcat}/{page}/{viewall}",
new
{
controller = "Category",
action = "Index",
cat = UrlParameter.Optional,
subcat = UrlParameter.Optional,
page = UrlParameter.Optional,
viewall = UrlParameter.Optional
}
);
View
<%: Html.RouteLink("Women's", "Category", new { cat = "Women", subcat = "" })%>
This is how it renders
<a href="">Women's</a>
解决方案
It's a regression bug, as explained by Phil Haack [ http://haacked.com/archive/2011/02/20/routing-regression-with-two-consecutive-optional-url-parameters.aspx ]
这篇关于asp.net MVC3 RouteLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文