Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was curious why this didn't work, so I had a little look.</p> <p>When you put code into the App_Code folder, it inherits from <code>System.Web.WebPages.HelperPage</code> and although this has a <code>Html</code> property, it's a <code>System.Web.WebPages.HtmlHelper</code> and not a <code>System.Web.Mc.HtmlHelper</code>, which is why you can't find things like ActionLink on it :(</p> <p>I had a quick look around, and <a href="https://stackoverflow.com/questions/4710853/using-mvc-htmlhelper-extensions-from-razor-declarative-views/4716933#4716933">found this answer from Andrew Nurse</a>:</p> <blockquote> <p>Omar's got the right answer here, but I wanted to add something (do feel free to mark Omar's response as the answer).</p> <p>We were aware of this in v1 and weren't able to get a great fix in the product, but David Ebbo (an architect on the ASP.Net team) posted a sample of a Visual Studio Code Generator that is basically a first exploration of the kind of ideas we're looking at to make this work properly: <a href="http://blogs.msdn.com/b/davidebb/archive/2010/10/27/turn-your-razor-helpers-into-reusable-libraries.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/davidebb/archive/2010/10/27/turn-your-razor-helpers-into-reusable-libraries.aspx</a></p> <p>Try that out and see what you think! Let David know if you have comments by posting on his blog.</p> </blockquote> <p>Unfortunately, it looks like you can't even put the Helper outside of App_Code into your Layout class or _ViewStart :(</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload