3

I have some custom Html helpers for my Asp.net MVC 3 app. In the main application they work correctly as I have put the following in my Web.Config:

<pages clientIDMode="AutoID">
  <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.Routing" />
    <add namespace="System.Web.WebPages"/>
    <add namespace="WebDibaelsaMVC.Utils.HtmlHelpers" />
    <add namespace="WebDibaelsaMVC.Utils.HtmlHelpers.DTOs" />
  </namespaces>
</pages>

but I have now created an area and to make my custom helpers work I have to add a using in every page where I use them. Is there a way to add the default namespaces for that area?

Carles Company
  • 7,118
  • 5
  • 49
  • 75

1 Answers1

5

If you are using Razor you might need to add the reference to the <namespaces> section in the ~/Views/web.config and ~/Areas/YourAreaName/Views/web.config and not the main ~/web.config file. Also make sure you recompile the project, open close the view, maybe even restart Visual Studio for changes to take effect (in terms of Intellisense, it will work if you run the project).

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928