iltelko iltelko - 3 months ago 39
C# Question

Where C# System.Web.Mvc Controller class is located, in adding references?

I am trying to create subclass of class "Controller" which is located in System.Web.Mvc namespace. According to source (https://msdn.microsoft.com/en-us/library/system.web.mvc.controller(v=vs.118).aspx), it is located in System.web.mvc.dll. I added as reference the "System.Web" in Visual Studio and also tried some other namespaces like System.Web.Abstractions, but I am not able to reference to Controller / System.web.mvc namespace. That dll (System.web.mvc.dll) is not listed in the references, or in extensions. What I am doing wrong?

Answer Source

Maybe you need to actually install MVC. In Visual Studio, go Tools > Nuget package manager > package manager console, then type:

 Install-Package Microsoft.AspNet.Mvc -Version *requiredVersion*

e.g. (latest stable release)

 Install-Package Microsoft.AspNet.Mvc -Version *requiredVersion* 5.2.3