Alex Rivera | Logout

Razor can not find my HTML helper

Asked 2012-11-12T20:37:07.213
12

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?

Edit
Report

1 Answer

18

you also need to reload your solution

answered 2012-11-12T20:40:20.063

Your Answer