title: ASP MVC 5 Html.EditorFor not working / Unable to access/use Default Editor Templates
body: <p>While attempting access/use the default editor templates in MVC5.</p>
  
  <p>I receive the error:</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'System.String',
    but this dictionary requires a model item of type
    'MvcContrib.UI.InputBuilder.Views.PropertyViewModel`1[System.Object]'.</p>
  </blockquote>
  
  <p><strong>Why is this happening?</strong></p>
  
  <p>Some background:</p>
  
  <p>My model (TestModel.cs):</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace MyTest.Web.Controllers.Models
  {
      public class TestModel
      {
          public TestModel()
          {
              Name = "Fred";
          }
  
          public string Name { get; set; }
  
      }
  }
  </code></pre>
  
  <p>My Controller (MyTestController.cs):</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace MyTest.Web.Controllers
  {
      public class MyTestController : Controller
      {
          [HttpGet]
          public ActionResult Index()
          {
              TestModel testData = new TestModel();
              return View(testData);
          }
  
          ...
  
      }
  }
  </code></pre>
  
  <p>My View (Index.cshtml):</p>
  
  <pre class="lang-cs prettyprint-override"><code>@model MyTest.Web.Controllers.Models.TestModel
  @{
      ViewBag.Title = "MyTest";
      Layout = "~/Views/Shared/_Layout.cshtml";
  
  }
  &lt;div class="mainDisplay"&gt;
      &lt;h2&gt;Test&lt;/h2&gt;
      &lt;div&gt;
          @using (Html.BeginForm("ProcessResults", "MyTest", FormMethod.Post))
          { 
              &lt;div style="display:block;"&gt;
                  &lt;div style="display:inline;"&gt;Name:&lt;/div&gt;
                  &lt;div style="display:inline;"&gt;@Html.EditorFor(x =&gt; x.Name)&lt;/div&gt;
              &lt;/div&gt;
              &lt;div style="display:block;"&gt;
                  &lt;input type="submit" name="Submit" value="Submit" /&gt;
              &lt;/div&gt;
          }
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The error occurs on the following line</p>
  
  <blockquote>
  <pre><code>&lt;div style="display:inline;"&gt;@Html.EditorFor(x =&gt; x.Name)&lt;/div&gt;
  </code></pre>
  </blockquote>
  
  <p><strong>and the view will not render</strong></p>
  
  <p>Things I have tried:</p>
  
  <ul>
  <li>The sample from "<a href="http://www.edandersen.com/2013/05/28/asp-net-mvc-basics-part-1-view-model-binding/" rel="nofollow">ASP.NET MVC Basics Part 1: View Model binding</a>" and this sample works without a problem.</li>
  <li>If I add a custom editor template under <code>~/Views/Shared/EditorTemplates/Name.cshtml</code> and I invoke <code>@Html.EditorFor(x =&gt; x.Name, "Name")</code> then the page renders</li>
  <li>If I change the code to be <code>@Html.TextBoxFor(x =&gt; x.Name, "Name")</code> then the page renders</li>
  </ul>
  
  <p>Finally, the solution has System.Web.Mvc assembly (which should contain the default editor templates).</p>
  
  <p><strong>What am I missing?</strong></p>