如何从App_Code文件夹中的Razor帮助器中使用Url.Action()?
我根据Why I cant use Html.RenderPartial in razor helper view File in App_Code Folder?尝试过
@using System.Web.Mvc.Html
@helper Tabel(System.Web.Mvc.HtmlHelper html)
{
@Html.Raw(Url.Action("Index", "Home"))
}
但出现编译错误
CS0103:名称'Url'在当前上下文中不存在
使用ASP.NET MVC4和jquery。
[Html.Raw()
使用HtmlHelper
类,但是Url.Action()
使用UrlHelper Class类,因此您也需要通过它]]
@using System.Web.Mvc
@helper Tabel(HtmlHelper html, UrlHelper url)
{
html.Raw(url.Action("Index", "Home"))
}
这对我也很有效,没有传递参数: