title: How to pass viewmodel to a layout/master page?
body: <p>Having googling for some time, I'm a little bit confused with how to do this in asp mvc 3.</p>
  
  <p>So, the task is to have a common layout (or master?) page for several controllers' views. All the views are strongly-typed themselves... This layout page in fact visualizes some strongly-typed object. So, I need this object to be passed to the layout page to pass it to `Html.RenderPartial()' or to render it right in the page.</p>
  
  <p>The article <a href="http://www.asp.net/mvc/tutorials/older-versions/views/passing-data-to-view-master-pages-cs" rel="nofollow noreferrer">Passing Data to View Master Pages (C#)</a> (though an old one for mvc2) gives an example to provide a base abstract controller class, passing the model to <code>ViewData</code>. This could be the cure. </p>
  
  <p>But...</p>
  
  <p>In some threads I found a way one could make a strongly-typed master page:</p>
  
  <pre><code>&lt;%@ Master ... Inherits="System.Web.Mvc.ViewMasterPage&lt;MyWeb.Models.Client&gt;" %&gt;
  </code></pre>
  
  <p>So, is there the same approach in mvc3? Or the only way to pass data to a layout page is to use ViewBag or ViewData?</p>
  
  <p>Having read <a href="https://stackoverflow.com/questions/7539384/what-is-the-best-way-to-bind-viewmodel-data-to-master-page-in-asp-net-mvc">what is the best way to bind ViewModel data to master page in asp.net-mvc</a>, I've considered Darin's answer, but still think that this bunch of views will have the same layout, and see no reason to go against DRY principle.</p>
  
  <p>So, how to pass strongly-typed objects to layout pages? Or have I mixed something up?</p>