The name 'viewbag' does not exist in the current context

CC 321 Reputation points
2021-06-24T22:12:57.693+00:00

Working on an MVC solution developed by team member that was pulled from Team Foundation Server, and have many error messages in this solution like:

  • The name 'viewbag' does not exist in the current context
  • The name 'HTML' does not exist in the current context
  • The type or namespace 'MVC' name does not exist in the namespace 'System.Web'
  • The type or namespace 'ActionResults' could not be found.
  • *** and many similar error messages

If I open another solution pulled from TFS, I don't get any of these types of syntax error messages.

Have checked the following to troubleshoot:
--I do have a web.config in my Views folder
--I've done multiple Cleans/Rebuild tries
--I've deleted files from C:\Users****\AppData\Local\Microsoft\VisualStudio\16.0_581ef021\ComponentModelCache
--Root web.config says <dependentAssembly> ... <bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,541 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,306 Reputation points
    2021-06-25T14:29:10.197+00:00

    A mvc project requires a project file and a packages file. Be sure the packages file is defined, and you did a nuget restore.

    0 comments No comments

  2. CC 321 Reputation points
    2021-06-25T14:38:13.92+00:00

    I do have a packages.config file

    I have these settings via Tools >> NuGet Package Manager >> Package Manager Settings:

    109462-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.