c# – Views don't recognize @model, @ViewBag, @ViewData


I'm using Mono 5.10.1 and Visual Studio Professional for Mac (Version 7.5.4 build 3)

Views do not recognize tags like @model, @ViewBag and @ViewData, both in old projects that were originally created in Visual Studio 2017 Windows, and in a simple new project using .Net Framework 4.6.1

I put in GIT a standard project created, even in it the Views do not recognize the tags, however downloading the project in a Visual Studio 2017 Windows the tags are recognized normally. GIT: https://github.com/DanielGregatto/TesteRazor

Has anyone ever experienced this? I've been searching for a few days now.


This happens because your project is not recognizing the Razor library.

Via NuGet, check which version of Razor is installed in your project. Then, access the packages.config and Web.config files and review the versions of this library. There may be more than one reference and be sure to check the Web.config file in the Views folder as well .

It is worth remembering that the packages.config file quotes the raw version of the package, which may be different from the version mentioned in Web.config .

Scroll to Top