title: How to fix namespace problem with autogenerated Master property if MasterType is set
body: <p>after weeks of having this issue I finally decided to ask for a solution to the following problem:</p>
  
  <p>In the .aspx page you can set  </p>
  
  <pre><code>&lt;%@ MasterType VirtualPath="~/Mastername.master" %&gt;
  </code></pre>
  
  <p>This results in an auto generated property in the .aspx.designer</p>
  
  <pre><code>public new Mastername Master {
      get {
          return ((Masternamee)(base.Master));
      }
  }
  </code></pre>
  
  <p>Works perfectly fine. But if I do changes in the .aspx file, the property will be new auto generated and it looks like the following:</p>
  
  <pre><code>public new NAMESPACE1.Mastername Master {
              get {
                  return ((NAMESPACE1.Mastername)(base.Master));
              }
          }
  </code></pre>
  
  <p>Compiling will not be possible afterwards, because the class for the MasterPage cannot be resolved at the given namespace.
  The masterpage has NAMESPACE1 as namespace.</p>
  
  <p>Every contentpage has the same NAMESPACE1.
  The autogenerated property tries to look for the masterpage class in NAMESPACE1.NAMESPACE1 which will fail, due to it does not exist. Of course I can remove the first NAMESPACE1. to make the app compilable again, but it just sucks to do this nearly every time I make changes in the .aspx file.</p>
  
  <p>Is there a way to avoid this problem? The only way I can think of, is to ignore the auto generated property and make a explicit cast everytime I want have access to the masterpage.</p>
  
  <p>Edit: I'm using Visual Studio 2008 Professional SP1.</p>