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?
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With