Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy don't my HtmlHelper extensions work?
    text
    copied!<p>I'm building an ASP.Net MVC website. Rather than have everything in one project, I've decided to separate the Web, Model and Controller out into different projects in the same solution, that reference each-other.</p> <p>The referencing goes like this:</p> <blockquote> <p>Web ---[references]---> Controller ---[references]---> Model</p> </blockquote> <p>Now I wanted to add 2 custom methods to the HtmlHelper class - they're called "IncludeScript" and "IncludeStyle". They each take a single string parameter, and generate a script or link tag respectively.</p> <p>I've created an extender class, according to documentation on the web, and written the two methods and compiled the application.</p> <p>Now, when I go into the Public.Master page (which is my main master-page, and one of the places where I intend to use these methods), I can enter code such as below:</p> <p><code>&lt;%= Html.IncludeScript("\js\jquery.js") %&gt;</code></p> <p>The IntelliSense picks up and IncludeScript method and shows me the syntax just fine. So I'd expect that everything should work.</p> <p>But it doesn't.</p> <p>Everything compiles, but as soon as I run the application, I get the following run-time error from line 14 of Default.aspx.cs:</p> <p><code>c:\\Projects\\PhoneReel\\PhoneReel.Web\\Views\\Shared\\Public.Master(11): error CS0117: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'IncludeScript'</code></p> <p>Here's the line of code that the error happens on:</p> <p><code>httpHandler.ProcessRequest(HttpContext.Current);</code></p> <p>Any ideas what could be going wrong here?</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