title: Passing a model property to a partial view
body: <p>I'm having trouble passing the correct data to a partial view, and I'm not sure why it is failing.</p>
  
  <p>Say I have models</p>
  
  <pre><code>public class SubModel {
    public string Wobble {get; set;}
  }
  
  public class MyModel {
    public SubModel Wibble {get; set;}
  }
  </code></pre>
  
  <p>and views </p>
  
  <pre><code>MyView.cshtml
  
  @model MyModel
  
  @Html.Partial("SomePartial", Model.Wibble)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>SomePartial.cshtml
  
  @model SubModel
  
  &lt;h1&gt;Victory!&lt;/h1&gt;
  </code></pre>
  
  <p>this fails with <code>The model item passed into the dictionary is of type 'MyModel', but this dictionary requires a model item of type 'MySubModel'</code></p>
  
  <p>When I change <code>MyView.cshtml</code> to</p>
  
  <pre><code>@model MyModel
  
  @Html.Partial("SomePartial", Model.Wibble, new ViewDataDictionary&lt;MySubModel&gt;(Model.Wibble))
  </code></pre>
  
  <p>It works as expected.</p>
  
  <p>Why do I need to explicitly pass a <code>ViewDataDictionary</code>? Why can't I just pass the model?</p>
  
  <p>Note: I'm using a library that does things that make me go hrm? a lot of the time. If the above behaviour is not expected, it might be this libraries fault.</p>