VS2019 ASP.NET Core MVC Razor - Views report syntax errors (but work fine)

Something I’ve noticed in Visual Studio is that the editor reports syntax errors in the views (.cshtml) files for code that is valid (and actually works).

For example, here is how the Index.cshtml that is initially created by the ASP.NET Core MVC/Razor-based Web Application project template looks in the VS2019 editor:

It indicates an error with the ViewData reference, although it works fine. I see the same thing with the _ViewStart.cshtml and the _ViewImports.cshtml files.

Water seems to be fine - I don’t see those errors reported.

The code does seem to work fine, so it is just in how the VS2019 editor interprets / reports possible code problems. Creating a similar C# application from the Microsoft built-in templates seems to be okay, so I’m assuming it has something to do with Mercury. It isn’t a deal breaker, but it would be nice if this worked properly, as for someone like me trying to learn ASP.NET Core, reports of errors that aren’t really errors just adds to the confusion!



I think this might be the VS editor getting confused with meddling from VC#. will log.

Thanks, logged as bugs://85988

Yes, I thought that might be the case, too. Thanks!


1 Like

Logged as bugs://E25106.