title: ASP.NET MVC '@model dynamic' not recognizing Model properties when partial view is in Shared folder
body: <p>Not a duplicate of:  <a href="https://stackoverflow.com/questions/4862122/mvc-razor-dynamic-model-object-does-not-contain-definition-for-propertyname">MVC Razor dynamic model, &#39;object&#39; does not contain definition for &#39;PropertyName&#39;</a></p>
  
  <p>According to the answers there, </p>
  
  <blockquote>
    <p>According to David Ebbo, you can't pass an anonymous type into a
    dynamically-typed view because the anonymous types are compiled as
    internal. Since the CSHTML view is compiled into a separate assembly,
    it can't access the anonymous type's properties.</p>
  </blockquote>
  
  <p>Why does the code below - which allegedly should never work - work as I had expected when the partial view is located in "/Home/_Partial.cshtml", but suddenly stops working when moved to "/Shared/_Partial.cshtml"?</p>
  
  <p>Using ASP.NET 4.5 (and previous versions), the following produces the text "Hello, World!" to the web browser:</p>
  
  <p>~/Controllers/HomeController.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  
  namespace TestDynamicModel.Controllers
  {
      public class HomeController : Controller
      {
          public ActionResult Index()
          {
              return View();
          }
      }
  }
  </code></pre>
  
  <p>~/Views/Home/Index.cshtml</p>
  
  <pre><code>@Html.Partial("_Partial", new { Text = "Hello, world!", ShouldRender = true } )
  </code></pre>
  
  <p>~/Views/Home/_Partial.cshtml</p>
  
  <pre><code>@model dynamic
  @if (!Model.ShouldRender)
  {
      &lt;p&gt;Nothing to see here!&lt;/p&gt;
  }
  else
  {
      &lt;p&gt;@Model.Text&lt;/p&gt;
  }
  </code></pre>
  
  <p>However, when the _Partial.cshtml is instead moved to ~/Views/Shared/_Partial.cshtml, the following error is thrown in _Partial.cshtml (line 2):</p>
  
  <pre><code>'object' does not contain a definition for 'ShouldRender'
  </code></pre>
  
  <p>Upon inspecting the Model in the debugger, I find the following properties:</p>
  
  <pre><code>Model { Text = Hello, world!, ShouldRender = True }
  </code></pre>