title: problems upgrading MVC4 to MVC5
body: <p>I'm trying to upgrade MVC4 to MVC5, but weird things happen. I used <a href="http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2" rel="nofollow noreferrer">a pretty nice guide that I found</a> and everything compiles OK, but when I try to show the website I get this error:</p>
  
  <blockquote>
    <p>Could not load file or assembly 'System.Web.Helpers' or one of its
    dependencies. The located assembly's manifest definition does not
    match the assembly reference. (Exception from HRESULT: 0x80131040)</p>
  </blockquote>
  
  <p>The weird thing is that when I look at the assembly references to System.Web.Mvc, System.Web.Razor, System.Web.WebPages, etc, they are all still at the version numbers that belong to MVC4! I've tried to reinstall the corresponding nuget packages, which gave me the sort of output you'd hope to get:</p>
  
  <pre><code>PM&gt; Update-Package -reinstall -Id Microsoft.AspNet.Razor
  Removing 'Microsoft.AspNet.Razor 3.2.3' from LabManager.Web.
  Successfully removed 'Microsoft.AspNet.Razor 3.2.3' from LabManager.Web.
  Uninstalling 'Microsoft.AspNet.Razor 3.2.3'.
  Successfully uninstalled 'Microsoft.AspNet.Razor 3.2.3'.
  Installing 'Microsoft.AspNet.Razor 3.2.3'.
  You are downloading Microsoft.AspNet.Razor from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
  
  Successfully installed 'Microsoft.AspNet.Razor 3.2.3'.
  Adding 'Microsoft.AspNet.Razor 3.2.3' to LabManager.Web.
  Successfully added 'Microsoft.AspNet.Razor 3.2.3' to LabManager.Web.
  </code></pre>
  
  <p>which suggests that the correct versions have been installed. However, still the System.Web.Razor reference shows that it is at version 2.0.0.0. Also, I am compiling for .NET version 4.5.1, but the Runtime version of System.Web.Razor still shows 4.0.3.0319. The same goes for all the MVC related assemblies (except that the version number for System.Web.Mvc is 4.0.0.0 instead of 5.x.x.x).</p>
  
  <p>Help! Does anyone have a clue what is going on here?</p>
  
  <p>Edit: Here is my Web.Config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
  
  For more information on how to configure your ASP.NET application, please visit
            http://go.microsoft.com/fwlink/?LinkId=152368
            --&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
  
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;&lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;add name="LabManagerEntities" connectionString="metadata=res://*/Models.LabManagerEntities.csdl|res://*/Models.LabManagerEntities.ssdl|res://*/Models.LabManagerEntities.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=.\SQLServer;Initial Catalog=mne_labbeheer_prd1;Integrated Security=True;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;
      &lt;add name="ApplicationServices" connectionString="Data Source=.\SQLServer;Initial Catalog=mne_labbeheer_prd1;Integrated Security=True" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="webpages:Version" value="3.0.0.0" /&gt;
      &lt;!--&lt;add key="webpages:Enabled" value="false" /&gt;--&gt;
      &lt;add key="PreserveLoginUrl" value="true" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
      &lt;!-- IP addresses allowed to view IP Address Restricted portions of the website. 
            An asterisk indicates an entire subnet is valid. --&gt;
      &lt;add key="AuthorizeIPAddresses" value="::1,127.0.0.1" /&gt;
    &lt;/appSettings&gt;
    &lt;!--
      For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
  
      The following attributes can be set on the &lt;httpRuntime&gt; tag.
        &lt;system.Web&gt;
          &lt;httpRuntime targetFramework="4.5.1" /&gt;
        &lt;/system.Web&gt;
    --&gt;
    &lt;system.web&gt;
      &lt;globalization culture="en-US" /&gt;
      &lt;compilation debug="true" targetFramework="4.5.1"&gt;
        &lt;assemblies&gt;
          &lt;add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
        &lt;/assemblies&gt;
      &lt;/compilation&gt;
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
      &lt;/authentication&gt;
      &lt;membership defaultProvider="DefaultMembershipProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;profile defaultProvider="DefaultProfileProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
      &lt;roleManager enabled="true" defaultProvider="DefaultRoleProvider"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" /&gt;
          &lt;add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;pages controlRenderingCompatibilityVersion="5.0"&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Helpers" /&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
      &lt;httpRuntime maxRequestLength="104857600" /&gt;
      &lt;!--
              If you are deploying to a cloud environment that has multiple web server instances,
              you should change session state mode from "InProc" to "Custom". In addition,
              change the connection string named "DefaultConnection" to connect to an instance
              of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
        --&gt;
      &lt;sessionState mode="InProc" customProvider="DefaultSessionProvider"&gt;
        &lt;providers&gt;
          &lt;add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/sessionState&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"&gt;
        &lt;remove name="RoleManager" /&gt;
      &lt;/modules&gt;
      &lt;security&gt;
        &lt;requestFiltering&gt;
          &lt;requestLimits maxAllowedContentLength="104857600" /&gt;
        &lt;/requestFiltering&gt;
      &lt;/security&gt;
    &lt;/system.webServer&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;remove invariant="System.Data.SqlServerCe.4.0" /&gt;
        &lt;add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
      &lt;!-- When targeting ASP.NET MVC 3, this assemblyBinding makes MVC 1 and 2 references relink
            to MVC 3 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it.
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
        --&gt;
      &lt;!-- When targeting ASP.NET MVC 3, this assemblyBinding makes MVC 1 and 2 references relink
            to MVC 3 so libraries such as DotNetOpenAuth that compile against MVC 1 will work with it.
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
        --&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="mssqllocaldb" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>