0

I had Visual Studio 2017, Visual Studio 2019 and old project in .NET 4 (ASP.NET website). Everything works perfectly on Windows 10 64 bit the last build, then I uninstall VS 2017 today.

After I uninstalled Visual Studio 2017, I now get this error:

Error CS0103 The name 'ViewBag' does not exist in the current context Error CS0103 The name 'model' does not exist in the current context

But when I check Visual Studio Installer I have already .NET Framework 4 and ASP.NET MVC 4 installed.

I have this in my web.config file:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Am I missing an ASP.NET MVC 3 framework? But when I try to install I got this error:

enter image description here

Is there any solution?


Update:

I try this solution: The name 'ViewBag' does not exist in the current context - Visual Studio 2015, but does not work for me

I got this error: enter image description here

But when I check it in Visual Studio 2019 Installer, I had already installed enter image description here

I also try to install Visual Studio 2017 back and VS 2015, but I had still the same error and is it not possible to install ASP MVC 3 But when I run webapp in Visual Studio, webpage works fine

Jan Sršeň
  • 1,045
  • 3
  • 23
  • 46
  • Possible duplicate of [The name 'ViewBag' does not exist in the current context - Visual Studio 2015](https://stackoverflow.com/questions/29319189/the-name-viewbag-does-not-exist-in-the-current-context-visual-studio-2015) – Mohsin Mehmood Jul 30 '19 at 13:27
  • Why not use the latest MVC 5 anyway? The other versions are out of date now. Maybe VS2019 does not support them – ADyson Jul 30 '19 at 13:56
  • Because this system is big and uses old Windows Server which supports only .NET 4 – Jan Sršeň Jul 30 '19 at 18:35

2 Answers2

0

Check your MVC framework version, you need to have MVC framework 4.0. You can try to install from this link https://www.microsoft.com/ru-ru/download/details.aspx?id=30683

-1

I have no MVC 3 project. So this is just guessing.

The Visual Studio Installer for 2019 only shows support for MVC 4. enter image description here

Maybe this download helps. If it is not what you already tried.

bdongus
  • 658
  • 4
  • 20
  • I try it this before and Setup gives me a message then **Update does not apply** for MVC 3 exe file and in VS Installer I already had installed ASP.MVC 4 and .NET Framework 4 – Jan Sršeň Jul 31 '19 at 04:20