Anton Anton - 1 year ago 96
ASP.NET (C#) Question

Compilation error "type or namespace name does not exist in the namespace" - simple MVC project

Created "helloworld" project with MVC 5 in VS 2013 Ult. After hit Start button get following error in IE:

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

ASP.Net version is 4.5.1
System.Web.Mvc is in References with Version (Runtime version v4.0.30319)

Here's a part of web.config:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="mvc2" />

Tried to update mvc package:

PM> Install-Package Microsoft.AspNet.Mvc -Version 4.5.1
No updates available for 'Microsoft.AspNet.Mvc'.

What else could I try?

Answer Source

Set Copy Local = True for System.Web.Mvc Reference in Solution Explorer (by selecting the reference and clicking F4).