I have updated the NuGet package "Microsoft ASP.NET MVC" and dependencies from version 5.0.0.0 to version 5.2.2.0
To have all references refer to the correct assambly I have updated Views/Web.config manually (like described in most solutions on stack overflow and most tutorials). this results in the following configuration:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="System.Text.RegularExpressions"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Everything builds, however it breaks intellisence on all .cshtml razor pages:
The name 'model' does not exist in the current context
When I set the host factoryType version to 5.0.0.0 intellisence works again. The strange thing is this in not a refered assembly.
I have tried these solutions:
- remove obj folder, bin folder and all packages from solution and rebuild
fix
Copy Local = True
or<Private>True</Private>
from stack overflow<Reference Include="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll</HintPath> <Private>True</Private> </Reference>
tried to change version of
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, ..." ... />
Do you know why this issue occurs, and how the intellisense can use the 5.0.0.0 version while that assembly is not even in the packages folder? (I checked)