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>

OR

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



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

<html goes here>
    ...
</html>



Your Thoughts?

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

WordPress.com Logo

You are commenting using your WordPress.com 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