36

I'm new to ASP.NET MVC 5 and I wanted to build a small project to figure some things out. When i opened the project in the browser I got an error saying:

Compiler Error Message: CS0234: The type or namespace name 'Ajax' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)

Source Error:
Line 22:     using System.Web.WebPages; 
Line 23:     using System.Web.Mvc;      
Line 24:     using System.Web.Mvc.Ajax;  
Line 25:     using System.Web.Mvc.Html;  
Line 26:     using System.Web.Routing;

After some googling i found out that you had to change "Copy Local" to true but i saw that it was already set to true in my project. Even after a clean and a rebuild this error persists.

So does anyone have an idea about what could cause this error?

1
  • What version of System.Web are you referencing?
    – Ross Bush
    Commented Nov 7, 2014 at 15:56

8 Answers 8

90

I think you are referencing an older version of System.Web. Right-click the project in vs and select 'Manage NuGet Packages' then search for Asp.Net MVC and click install. This will install the proper System.Web with Ajax. You can remove the six other binaries downloaded if they are not needed.

1
  • I wish I'd had this information before I spent many, many hours trying to fix it myself. Thanks.
    – David Ward
    Commented Jan 2, 2015 at 22:00
18

Using MVC 5.2.3, I came across the same issue; it was out of the blue (This error came out of no where without making any changes, as the app was compiling and running smoothly before)

Fix:

  • Right-click the Solution and select "Manage NuGet Packages For Solution"
  • Uninstall the ASP.NET MVC by selecting Uninstall button
  • Deselect the Project that uses ASP.NET MVC - click Ok
  • Now install ASP.net MVC by finding it in NuGet window under the Online tab and install it for the project it was deselected for previously
  • That should solve the problem as it did for me. Enjoy!
1
  • Alternate solution for command line fans - open Package Manager Console and run command Update-Package –reinstall Microsoft.AspNet.Mvc Commented Aug 23, 2016 at 10:38
4

Running Install-Package Microsoft.AspNet.Mvc in the NuGet Package Manager Console did the trick for me.

3

Navigate to References and right click on the system.web.mvc

View properties and change Copy Local to True instead of False .

enter image description here

This did the trick for me in addition to run update package command in Package Manager Console.

2
  • The asker states in their question that they already did this...
    – Synctrex
    Commented May 1, 2020 at 20:41
  • yes, but I also mentioned package update using the console, and clearly mentioned above. thanks for identification Commented May 2, 2020 at 17:56
1

Set System.Web.MVC CopyLocal as True That helped for me

0

I updated the MVC from the NuGet Package Manager Console and solved my problem

0

Reopen the Visual Studio in Administrator mode.

0

Right-click the Solution and select "Manage NuGet Packages For Solution" Uninstall the ASP.NET MVC by selecting Uninstall button Deselect the Project that uses ASP.NET MVC - click Ok Now install ASP.net MVC by finding it in NuGet window under the Online tab and install it for the project it was deselected for previously That should solve the problem as it did for me. Enjoy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.