title: dynamic type in mvc view
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5120317/dynamic-anonymous-type-in-razor-causes-runtimebinderexception">Dynamic Anonymous type in Razor causes RuntimeBinderException</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to use a dynamic type model in my MVC application. I have the following code:
  in controller:</p>
  
  <pre><code>var model = new { Name = "test name", Family = "m" };
  return this.View(model);
  </code></pre>
  
  <p>and in the view I have:</p>
  
  <pre><code>@model dynamic
  
  @if(Model!=null)
  {
     &lt;p&gt; @Html.Raw(Model.Name) &lt;/p&gt;
  }
  </code></pre>
  
  <p>When I am running this, I am getting the following error :</p>
  
  <pre><code>'object' does not contain a definition for 'Name'   (System.Exception {Microsoft.CSharp.RuntimeBinder.RuntimeBinderException)
  </code></pre>
  
  <p>Why do I get this error?
  During debug, if I put my cursor on @Model, I can see that it has two property called Name and Family.</p>