title: ASP MVC - Razor Layout always receiving Page's Model
body: <p>All my pages in my site's layout inherits from a master layout. Whenever I stick a debug breakpoint in my Layout view, I can see that the layout class's Model is the same Model as the controller passes to its View. My layout files are untyped (no @model declarations except in the page itself)</p>
  
  <p>Also, any "RenderPartials" calls that happen inside this Layout passes this model along to other views.</p>
  
  <p>Is this correct?</p>
  
  <p>This means I can do @Model.SomeProperty in my layout which will work/not work depending on whether I visit a page which has a Model class with a "SomeProperty" property!</p>
  
  <p>An example:</p>
  
  <p>Page.cshtml</p>
  
  <pre><code>@model Project.PageModel
  Layout = "/Views/Layout/Master.cshtml";
  </code></pre>
  
  <p>Master.cshtml:</p>
  
  <pre><code>Html.RenderPartial("../Layout/_Footer", null, null);
  </code></pre>
  
  <p>_Footer.cshtml:</p>
  
  <pre><code>@Html.Raw(Model.GetType().ToString())
  
  
  &lt;div class="blah"&gt;    
      ...
  &lt;/div&gt;
  </code></pre>
  
  <p>Viewing this page outputs "Project.PageModel", even though it has no model declaration, and I am explicitly passing it a NULL model and a NULL ViewDataDictinary. I can then call properties on this model from inside a partial rendered by the master layout.</p>