我在Global.asax中有这个路由值
routes.MapRoute(“Default”,// Route name“ / / ”,//带参数new {controller =“Home”,action =“Index”,id = UrlParameter的URL . 可选} //参数默认值); routes.MapRoute(
“编辑”,//路线名称
“Admin / / / ”,//带参数的网址
new {controller =“Edit”,action =“Index”,id = UrlParameter.Optional} //参数默认值
);
我使用此ActionLink方法来调用编辑路线
@Html.ActionLink("Edit", "Topic", "Edit", new { id = item.ID })
现在生成链接的结果就像这样......
http://localhost:777/Admin/Topic?Length=4
如何使用ActionLink方法正确使用路径和目标 .
谢谢!
1 回答
使用正确的
ActionLink
重载来获得预期的结果超载是
ActionLink(string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
在为操作提供参数时,必须将
null
添加为空HTML属性 . 或者,如果您确实需要将HTML属性应用于链接,则可以使用: