'Ajax' does not exist in the namespace 'System.Web.Mvc'

Mike van L picture Mike van L · Nov 7, 2014 · Viewed 54.2k times · Source

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?

Answer

Ross Bush picture Ross Bush · Nov 7, 2014

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.