15

I'm working on an ASP.NET MVC application, but I'm trying to remove everything but Controller code from my project and put it in it's own Class Library.

I've got some code that is
Using System.Web.Mvc;

But it doesn't seem to be letting me access it. I have Referenced the System.Web Namespace in the project.

Bassically I'm getting errors on the iActionFilter and the FilterAttribute stuff.

What am I missing?

Chase Florell
  • 46,378
  • 57
  • 186
  • 376

5 Answers5

12

Turns out that the System.Web.MVC Assembly is NOT installed in the GAC. It has to be referenced from
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies

Chase Florell
  • 46,378
  • 57
  • 186
  • 376
  • 2
    Oh yes, that's a good point. It actually is in the GAC, but something that trips a lot of people up is the fact that the ".NET" tab on the Add References window is actually *not* just an enumeration of the GAC. [See here for more details](http://stackoverflow.com/questions/495973/getting-assemblies-to-show-in-the-net-tab-of-add-reference) – Dean Harding Jun 04 '10 at 05:09
6

Web.Mvc was not in Extensions for me. You can install if from nuget:

PM> Install-Package Microsoft.AspNet.Mvc
Chuck D
  • 1,629
  • 2
  • 16
  • 32
  • 1
    That makes total sense... To install System.Web.Mvc, install Microsoft.AspNet.Mvc. =) Worked for me! – Scuzzlebutt Mar 02 '19 at 23:24
  • I once read somewhere, "Naming things is hard". I agree with the author of that statement. And also feel the pain when things aren't named as any sane person would expect. =) – Scuzzlebutt Mar 12 '19 at 18:57
5

you can go to :

Add Reference > Assemblies > Extentions and add system.web.mvc :)

Farhad Shekari
  • 2,245
  • 1
  • 14
  • 12
1

I believe the MVC stuff is in the System.Web.Mvc assembly. There should be nothing wrong with referencing that from a class library.

Dean Harding
  • 71,468
  • 13
  • 145
  • 180
0

For MVC 4 it is installed to:

C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies

Development Note:

I am always cautious about including non-GAC assemblies from a fixed drive location (which may vary between machines, or not be installed at all). Instead I would create a ~/ThirdParty/Microsoft/Microsoft ASP.NET/ASP.NET MVC 4/Assemblies folder, in source control, and copy the assemblies there for all machine to reference.

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202