Global Namespace Includes with MVC and Razor

PUBLISHED ON MAR 7, 2011

While I’m loving MVC3 and the Razor view engine, I was sorely disappointed when I couldn’t use the system.web/pages/namespaces collection in web.config to add global namespace includes.

After a bit of hunting and looking through the web.config files underneath the views folder (in each Area), I found that this can be accomplished by adding the following to the root web.config file:

Now you can add any namespaces you require under the new razor namespaces section.

TAGS: .NET, MVC, RAZOR
comments powered by Disqus