Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using default namespaces in .NET MVC for views without using import?

How do you configure the views to able to reference a namespace like System.Web.Mvc without having to do <%@ Import Namespace="System.Web.Mvc" %>? I remember seeing this somewhere but my google skills are failing me at the moment.

like image 535
jdelator Avatar asked Mar 16 '09 08:03

jdelator


People also ask

Which are the important namespaces used in MVC?

The System. Web. Mvc namespace contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial view, model binders, and much more.


1 Answers

Can you add them in web.config? Don't know if this works in MVC, though...

<configuration>
 <system.web>
    <pages>
      <namespaces>
        <add namespace="Foo.Blop" />
        <add namespace="Bar.Whatever"/>
      </namespaces>
    </pages>  
 </system.web>
</configuration>

(update - seems to work fine ;-p)

like image 139
Marc Gravell Avatar answered Nov 02 '22 01:11

Marc Gravell