我有一个自定义助手需要调用Html.ActionLink
@helper GetLink(int id, string name)
{
@Html.ActionLink(name, "Index", "MyController", new { id = id }, null);
}
它在另一个页面上完美运行但在我的自定义帮助程序中(称为customhelpers.cshtml并位于App_Code文件夹中)我收到以下错误:
'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'ActionLink' and the best extension method overload 'System.Web.Mvc.Html.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' has some invalid arguments
这意味着它无法找到Html.ActionLink类,但我尝试引用相关的命名空间(@using System.Web.MVC.Html),但无济于事。