我想将一个像字符串一样的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
我在这里做错了什么?
答案 0 :(得分:2)
您使用ActionLink
的错误重载。您应该使用this重载:
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)