How to include / import a namespace in an MVC View

Tired of all of those crazy-long namespaces all over your view?

Add the using statement to your view if you are using the Razor engine:

@using My.Namespace.Path 

@{ ViewBag.Title = "My Page"; ... } <html goes here> ... </html>


Add the import statement If you are using the ASP.NET (C#) engine:

<%@ Import Namespace="My.Namespace.Path" %> 

<html goes here>

Your Thoughts?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s