title: Changing base view type on MVC4
body: <p>I've read a post about changing base view type on MVC from the link below:</p>
  
  <p><a href="http://haacked.com/archive/2011/02/21/changing-base-type-of-a-razor-view.aspx" rel="noreferrer">http://haacked.com/archive/2011/02/21/changing-base-type-of-a-razor-view.aspx</a></p>
  
  <p>I followed the instructions but my page still inherits from <code>System.Web.Mvc.WebViewPage</code>. I can't reach any property defined in my custom view base and I get an error on runtime. When I use <code>@inherits</code> keyword, it fixes. </p>
  
  <p><strong>Web.config</strong></p>
  
  <pre><code>&lt;pages pageBaseType="[MyNamespace].WebViewPageBase"&gt;
    &lt;namespaces&gt;
      &lt;add namespace="System.Web.Helpers" /&gt;
      &lt;add namespace="System.Web.Mvc" /&gt;
      &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
      &lt;add namespace="System.Web.Mvc.Html" /&gt;
      &lt;add namespace="System.Web.Optimization" /&gt;
      &lt;add namespace="System.Web.Routing" /&gt;
      &lt;add namespace="System.Web.WebPages" /&gt;
    &lt;/namespaces&gt;
  &lt;/pages&gt;
  </code></pre>
  
  <p><strong>WebViewPageBase</strong></p>
  
  <pre><code>public class WebViewPageBase : WebViewPage
  {
      public SomeType MyProperty { get; set; }
  
      public override void InitHelpers()
      {
          base.InitHelpers();
          MyProperty = { foo };
      }
  
      public override void Execute()
      {
  
      }
  }
  
  
  public class WebViewPageBase&lt;T&gt; : WebViewPage&lt;T&gt;
  {
      public SomeType MyProperty { get; set; }
  
      public override void InitHelpers()
      {
          base.InitHelpers();
          MyProperty = { foo };
      }
  
      public override void Execute()
      {
  
      }
  }
  </code></pre>
  
  <p><strong>Partial View</strong></p>
  
  <pre><code>@model TopMenuModel
  
  &lt;div class="topMenu"&gt;
  @MyProperty
  &lt;/div&gt;
  </code></pre>
  
  <p>But in the post I've read there is no instruction about <code>@inherits</code> keyword. Is there any thing that I miss or any way to make this work without <code>@inherits</code> keyword in all pages?</p>
  
  <p><strong>SOLVED:</strong></p>
  
  <p><code>web.config</code> file in <code>root</code> directory is not the right one. I changed base type in the <code>web.config</code> file under <code>View</code> directory and it fixed.</p>