There are two methods in which you can add a namespace to a Razor view in ASP.NET MVC 3.

Method 1
The first way is to use the @using statement in .cshtml files, which imports a namespace to the current file only.

Example :-

@using Namespace1
@using Namespace2.SomeClass

Method 2
and the second way is to define these namespaces in the web.config of the View directory of your project.


  <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />
      <!-- can more more here... -->

or you can add your custom namespace like this too :

<add namespace="Custom.Yasser" />
<add namespace="Custom.Mohsin" />