Search code examples
c#asp.net-core-mvcasp.net-core-5.0

VS 2019 - ASP.NET Core MVC web app (written in C#) : multiple errors on brand new project


Brand new project utilizing ASP.NET Core 5.0 MVC, and written in C#.

I'm getting multiple errors inside the Error List window when viewing any of the default .cshtml pages.

However, the project still builds and runs normally.

Errors include:

- The name 'ViewData' does not exist in the current context.
- The name 'RenderBody' does not exist in the current context.
- The name 'await' does not exist in the current context.
- The name 'Context' does not exist in the current context.
- The namespace "ASP" already contains a definition for '_Page_Default_cshtml' 

(For full list https://pastebin.com/YM5JnqBj)


Solution

  • It may be because you did not choose ASP.NET and .NET Cross-Platform Development when installing VS 2019. Only other environments were selected for development. I created my ASP.NET project without installing the correct modules. After noticing this, I went back and installed the two missing modules, but this did not solve the problem. Some links on the back end of VS 2019 are not established.

    The final solution-reinstall VS 2019 with the correct modules from the beginning (without trying to fix it first). Now all assistants, the code is complete, Intellicode, everything is normal.

    ERROR: enter image description here