Intellisense not working for Razor Views
Donnerstag, 4. Februar 2016
Sometimes when you upgrade ASP.NET MVC (e.g. from 4.0 to 5.x), you also update your WebPages Version (e.g. from 2.0 to 3.0) and then you encountered following error message:
The name 'ViewBag' does not exist in the current context
Usally this works after verifiying you have these lines in root web.config:
<add key="webpages:Version" value="3.0.0.0" />
and
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
Be aware there is also a web.config in your views folder, which has to be update to WebPages 3.0
<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>
Blog / Lothar Steidle
Letzte Einträge
Montag, 9. Januar 2023
Cool uses for css Variables
Freitag, 21. August 2020
Dynamische Hintergrundbilder ohne Inline Styles verwenden
ohne csp unsafe-inline
Dienstag, 1. Oktober 2019
Content-Security-Policy
Sichere Websites
Montag, 2. April 2018
Piwik/Matomo Opt Out Iframe funktioniert nicht
In einer Multidomain Installation
Freitag, 23. März 2018
Website mit Bootstrap druckt keine Hintergrundfarben
Alle anzeigen (10)
Beliebteste Einträge
Donnerstag, 4. Februar 2016
Intellisense not working for Razor Views
Montag, 7. Juli 2014
Send a Posted Form through Modelbinder as Email
In C# MVC
Mittwoch, 30. März 2016
Essential Visual Studio 2015 Extensions
for Webdevelopers
Montag, 6. Oktober 2014
How to use a font-awesome icon for submenu
...and animate it
Montag, 2. April 2018
Piwik/Matomo Opt Out Iframe funktioniert nicht
In einer Multidomain Installation
Alle anzeigen (10)