我有以下自定义助手:
<Extension> _
Public Function ActionLinkAuthorized(htmlHelper As HtmlHelper, linkText As String, actionName As String, controllerName As String, routeValues As RouteValueDictionary, htmlAttributes As IDictionary(Of String, Object)) As MvcHtmlString
If (Roles.IsUserInRole("Administrator")) Then
Return htmlHelper.ActionLink(linkText, actionName, controllerName, routeValues, htmlAttributes)
Else
Return MvcHtmlString.Empty
End If
End Function
这可以在我的剃刀视图中很好地看到,并且我尝试按如下方式使用它:
@Html.ActionLinkAuthorized("Edit", "Edit", "Account", New With {.id = currentItem.Id}, htmlAttributes:=New With {.class = "btn btn-warning", .title = "Edit"})
但是在运行我的应用程序时出现以下错误:
“(第 193 行)”类型的值无法转换为“System.Web.Routing.RouteValueDictionary”。
我对 VB.NET 完全陌生,不太确定我做错了什么。非常感激任何的帮助。