Razor can not find my HTML helper

asp.net-mvc-4, razor

Solution

It needs to be added to the config file in the Views folder, not the main config.

See this answer:

How do I import a namespace in Razor View Page?

Problem

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?

Original source

Related problems