title: Passing anonymous objects from a view to a partial view
body: <p>I understand from various other related questions <a href="https://stackoverflow.com/questions/4862122/mvc-razor-dynamic-model-object-does-not-contain-definition-for-propertyname">here</a> and <a href="https://stackoverflow.com/questions/223713/can-i-pass-an-anonymous-type-to-my-asp-net-mvc-view">here</a> among others, that you can't pass anonymously typed objects from the controller to the view because anonymous types are defined with the Internal accessor. The View and Controller code are compiled into different assemblies so attempting to use it results in this error...</p>
  
  <blockquote>
    <p>object does not contain a definition for 'foo'</p>
  </blockquote>
  
  <p>That is fine and I can accept that, although it was annoying at first. There are enough suggested workarounds to appease me.</p>
  
  <p>However, I thought you would still be able to pass an anonymous type from a view to a partial view because, both being views, they would be compiled in the same assembly.</p>
  
  <p>Razor View code...</p>
  
  <pre><code>@Html.Partial("Partial1", new { foo = "Something", bar = "Something else" })
  </code></pre>
  
  <p>and the partial view code for "Partial1"</p>
  
  <pre><code>@model dynamic 
  
  &lt;h1&gt;@Model.foo&lt;/h1&gt;
  &lt;span&gt;@Model.bar&lt;/span&gt;
  </code></pre>
  
  <p>The strange thing is, this WAS working at the beginning of a the development on a new MVC project, but as I added more views it just stopped working and now give me the same error that I mentioned above.</p>
  
  <p>It is as if I have reached a threshold where the view and partial view are no longer compiled into the same assembly. But I'm just guessing.</p>
  
  <p>I wonder if anyone can shed any light of this.</p>