jdelator
jdelator

Reputation: 4251

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.

Upvotes: 12

Views: 3555

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062975

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)

Upvotes: 21

Related Questions