Can I not add my project namespace to the web.config so that the Razor view engine includes my project namespace for all pages in my project? Like so:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<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 = "MyProjectNamespace.NestedNamespace"/>
</namespaces>
</pages>
</system.web.webPages.razor>
It isn't working.
This is an old question, but apparently there is still a bit of a problem with Visual Studio (2015 2017 2019 as of right now). After adding the namespaces to the web.config file in your Views folder, close and re-open all views. The namespaces were not recognized and the views would continuously throw runtime errors until I closed them all.