0

I have a DLL that contains extension methods and I want to be able to use them in all my views without having to manually add the @using MyLongNameSpaceHere in each of my files.

Is there a way to globally load a namespace in all my Razor engine view?

Muffun
  • 726
  • 1
  • 9
  • 27

1 Answers1

4

In the "~/views/web.config" file, use something as following:

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
        <namespaces>
            <add namespace="System.Web.Mvc.Ajax" />
        </namespaces>
    </pages>
</system.web.webPages.razor>
Siyavash Hamdi
  • 2,764
  • 2
  • 21
  • 32