我想将id这样的id传递给我的action方法,我这样做是
<li>@Html.ActionLink("Nokia Lumia Series", "Mobiles", "Products", new { id = "Lumia" })
这是我的行动方法
public ActionResult Mobiles(string name)
{
return View();
}
但它并未执行该操作,并且该网址显示在浏览器标签中
http://mymobiles.com/Home/Mobiles?Length=8
我在这里做错了吗?
您使用的不正确的重载ActionLink
。您应该使用此重载:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
Object routeValues,
Object htmlAttributes
)
然后,您的代码变成了,我也更改了参数名称以使其更加清晰:
@Html.ActionLink("Nokia Lumia Series", "Mobiles", "Products", new { name = "Lumia" }, null)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句