title: The model item passed into the dictionary is of type ‘mvc.Models.ModelA’ but this dictionary requires a model item of type ‘mvc.Models.ModelB‘
body: <p>I have this annoying mistake in some of my builds.</p>
  <p>There is no error in the project, because if I build again, then the problem disappears. The message only appears, when the site is deployed to a Windows 2008 Server.</p>
  <p>I first  thought that it might be an issue with temporary files, but thats not the case. I deployed the build to a different web and the error still appears.</p>
  <p>The error appears on random actions of the site. Most of the time builds are ok, but each 3rd or 4th build produces runtime errors.</p>
  <p>I build using a WebdeploymentProject in release mode. Views are precompiled.</p>
  <p>It's not <a href="https://stackoverflow.com/questions/178194/in-asp-net-mvc-i-encounter-an-incorrect-type-error-when-rendering-a-page-with-the">In ASP.NET MVC I encounter an incorrect type error when rendering a page with the correct typed object</a>, because views have totally different names.</p>
  <p>How I can debug this problem or how I can get help for this?</p>
  <p>Here is my WebDeploymentProject</p>
  <pre><code>    &lt;!-- 
        Microsoft Visual Studio 2008 Web Deployment Project 
        http://go.microsoft.com/fwlink/?LinkID=104956
  
      --&gt;
      &lt;Project ToolsVersion=&quot;3.5&quot; DefaultTargets=&quot;Build&quot; xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;&gt;
        &lt;PropertyGroup&gt;
          &lt;Configuration Condition=&quot; '$(Configuration)' == '' &quot;&gt;Debug&lt;/Configuration&gt;
          &lt;Platform Condition=&quot; '$(Platform)' == '' &quot;&gt;AnyCPU&lt;/Platform&gt;
          &lt;ProductVersion&gt;9.0.21022&lt;/ProductVersion&gt;
          &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
          &lt;ProjectGuid&gt;{E5E14CEB-0BCD-4203-9A5A-34ABA9C717EA}&lt;/ProjectGuid&gt;
          &lt;SourceWebPhysicalPath&gt;..\B2CWeb&lt;/SourceWebPhysicalPath&gt;
          &lt;SourceWebProject&gt;{3E632DB6-6DB3-4BD0-8CCA-12DE67165B48}|B2CWeb\B2CWeb.csproj&lt;/SourceWebProject&gt;
          &lt;SourceWebVirtualPath&gt;/B2CWeb.csproj&lt;/SourceWebVirtualPath&gt;
          &lt;TargetFrameworkVersion&gt;v3.5&lt;/TargetFrameworkVersion&gt;
        &lt;/PropertyGroup&gt;
        &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' &quot;&gt;
          &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
          &lt;OutputPath&gt;.\Debug&lt;/OutputPath&gt;
          &lt;EnableUpdateable&gt;false&lt;/EnableUpdateable&gt;
          &lt;UseMerge&gt;true&lt;/UseMerge&gt;
          &lt;SingleAssemblyName&gt;B2CWeb_Build&lt;/SingleAssemblyName&gt;
        &lt;/PropertyGroup&gt;
        &lt;PropertyGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Release|AnyCPU' &quot;&gt;
          &lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;
          &lt;OutputPath&gt;..\B2CWeb_Deploy\&lt;/OutputPath&gt;
          &lt;EnableUpdateable&gt;false&lt;/EnableUpdateable&gt;
          &lt;UseMerge&gt;true&lt;/UseMerge&gt;
          &lt;SingleAssemblyName&gt;B2C_Web&lt;/SingleAssemblyName&gt;
          &lt;ContentAssemblyName&gt;
          &lt;/ContentAssemblyName&gt;
          &lt;DeleteAppCodeCompiledFiles&gt;false&lt;/DeleteAppCodeCompiledFiles&gt;
        &lt;/PropertyGroup&gt;
        &lt;ItemGroup&gt;
        &lt;/ItemGroup&gt;
        &lt;Import Project=&quot;$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets&quot; /&gt;
        &lt;!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
             Other similar extension points exist, see Microsoft.WebDeployment.targets.
        &lt;Target Name=&quot;BeforeBuild&quot;&gt;
        &lt;/Target&gt;
        &lt;Target Name=&quot;BeforeMerge&quot;&gt;
        &lt;/Target&gt;
        &lt;Target Name=&quot;AfterMerge&quot;&gt;
        &lt;/Target&gt;
        &lt;Target Name=&quot;AfterBuild&quot;&gt;
        &lt;/Target&gt;
        --&gt;
      &lt;/Project&gt;
  </code></pre>
  <p><strong>EDIT</strong></p>
  <p>After some months this problem disapeared. I haven't had problems for over 1 year now. I guess the issue will strike again when nobody expects it.</p>
  <p><strong>EDIT 2</strong></p>
  <p>… for over 2 years now. I am such a lucky dude!</p>
  <p><strong>EDIT 3</strong></p>
  <p>I just read <a href="https://devblogs.microsoft.com/aspnet/enabling-the-net-compiler-platform-roslyn-in-asp-net-applications/" rel="nofollow noreferrer">an article on MSDN</a>, and it sounds like the problem I had. I have debugging disabled, but still the compilation was &quot;sometimes wrong&quot;. The behaviour of the old provider could be the issue. But this is just guessing.</p>
  <blockquote>
  <p>Very large pages containing long spans of HTML with no server blocks (e.g. &lt;%= %&gt;) can cause a stack overflow when debug compilation is enabled that will crash the application. Note that in our testing it’s taken a page that’s ~4x as large one that would’ve produced a similar issue in the old provider, but in this case it crashes the entire application, whereas with the old provider it just fails the offending page</p>
  </blockquote>