title: ASP.NET Core TypeLoadException Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System.Web'
body: <p>In the course of developing an ASP.NET Core MVC project, I have run into this exception multiple times. </p>
  
  <p>It happens when POSTing back to an MVC controller. Let's say the ViewModel looks like this:</p>
  
  <pre><code>using System.Web;
  
  namespace MyNamespace 
  {
      public class MyViewModel 
      {
          public List&lt;SelectListItem&gt; MyOptions { get; set; }
      }
  }
  </code></pre>
  
  <p>and the header for this view contains this</p>
  
  <pre><code>@model MyNamespace.MyViewModel
  </code></pre>
  
  <p>As mentioned, on POST back (assuming the View has a form and a postback in it) this exception is thrown.</p>
  
  <blockquote>
    <p>An unhandled exception occurred while processing the request.
        TypeLoadException: Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
        System.ModuleHandle.ResolveType(RuntimeModule module, int typeToken, IntPtr* typeInstArgs, int typeInstCount, IntPtr* methodInstArgs, int methodInstCount, ObjectHandleOnStack type)</p>
  </blockquote>