During the transition from ASP.NET MVC 4 to 5, a user encountered the following error:
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection.
Investigating the references in each project, deleting temp files, and verifying the installation of the updated System.Web.WebPages.Razor.dll seemed to hold no solution.
The issue lies in a project file still referencing the older version of System.Web.WebPages.Razor (1.0.0.0) instead of the updated version (3.0.0.0). To resolve this:
Updated Reference:
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Private>True</Private> <HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath> </Reference>
The above is the detailed content of Why Does My MVC 4 to MVC 5 Upgrade Fail with a 'System.Web.WebPages.Razor.Configuration.HostSection Cannot Be Cast' Error?. For more information, please follow other related articles on the PHP Chinese website!