Search code examples
vb.netasp.net-mvc-3rtmrazor

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)


Solution

  • 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.