Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor can not find my HTML helper

I am using VS Express 2012 for the Web. My project is a MVC 4 project.

I am trying to make a helper to create a menu item which is a png image with a label. I pretty much cut and pasted this code:

Action Image MVC3 Razor

When I try to use the helper razor can not find it.

I get this error:

CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'AddMenuItem' and no extension method 'AddMenuItem' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

My code looks like this: http://pastebin.com/cfsN99tF

I am trying to use this from _Layout.cshtml: http://pastebin.com/5vN8yYCa

I have added the namespace to Web.Config

<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
    <add namespace="HtmlHelperExtensions" />
  </namespaces>
</pages>

What else do I need to do?

like image 290
Anders E. Andersen Avatar asked Nov 12 '12 20:11

Anders E. Andersen


1 Answers

you also need to reload your solution

like image 193
Dmitry Efimenko Avatar answered Sep 19 '22 18:09

Dmitry Efimenko