MVC problem: 'HtmlHelper' does not contain a definition for 'Sitecore'

Hi.

I am normally used to Web Forms and I just started my first MVC project using Sitecore 9.

 

I get this error in my .cshtml files:

'HtmlHelper' does not contain a definition for 'Sitecore' and the best extension method overload 'HtmlHelperExtensions.Sitecore(HtmlHelper)' requires a receiver of type 'HtmlHelper'

 

I already included Sitecore's default "View" web.config file in the View folder.

 

If i hover over "@Html", i can see that it refers to System.Web.WebPages, instead of System.Web.Mvc.WebViewPage.

 

If i add "@inherits System.Web.Mvc.WebViewPage" to the top of my .cshtml file, it works. But i would like to avoid this.

 

I tried all the normal suggestions, like cleaning project, rebuilding, deleting VS cache, deleting .csproj.user and reloading project etc.

  • Please check your referenced versions in your views web.config with the assemblies you referenced in your project.

    Example: System.Web.Mvc 5.2.3 is referenced in your web.config but you referenced System.Web.Mvc 5.2.4

    Close your opened views after you changed the settings and validate it again if its working now.