I've created a global .cshtml Razor file in the App_Code folder of my MVC project to declare @helper functions. The problem is I can't use Html.ActionLink (or the other extensions) in the helper functions. I have tried to import the classes via a @using but that didn't work. Any ideas?
You could add the following line to your helper, to define Html
var Html = ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Html;
(Copied from this answer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With