How to use Url.Action in Razor view in App_Code folder
How to use Url.Action () in Razor helper from App_Code folder?
I tried according to Why can't I use Html.RenderPartial in the browser helper list in the App_Code folder?
@using System.Web.Mvc.Html
@helper Tabel(System.Web.Mvc.HtmlHelper html)
{
@Html.Raw(Url.Action("Index", "Home"))
}
but got compile error
CS0103: The name "Url" does not exist in the current context
ASP.NET MVC4 and jquery are used.
+3
source to share
2 answers
Html.Raw()
uses a class HtmlHelper
but Url.Action()
UrlHelper Class so you will need to pass that as well
@using System.Web.Mvc
@helper Tabel(HtmlHelper html, UrlHelper url)
{
html.Raw(url.Action("Index", "Home"))
}
+5
user3559349
source
to share