Ropstah Ropstah - 3 months ago 6x Question

Namespace reference in .NET MVC3 Razor view in VB?

How do I reference a Namespace in .NET MVC3 with the Razor view engine?

I understand this can be done in C#:

@using Namespace;

However in VB this doesn't seem to work:

@Imports Namespace

(i'm talking about inside a .vbhtml file)


You're using the correct syntax for VB:

@Imports My.Full.Namespace

What I've found in a quick play around is:

  • Sub namespaces of the MVC project will be picked up by intellisense once the @Imports statement is added - must be the complete namespace.
  • If you're referencing a namespace outside of the current MVC project then intellisense won't pick it up unless you do a rebuild.