Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use System.Web.Mvc from a Class Library?

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?

like image 433
Chase Florell Avatar asked Jun 04 '10 04:06

Chase Florell


People also ask

What is System Web MVC?

The System. Web. Mvc namespace contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial view, model binders, and much more.

How can use Class Library in ASP NET MVC?

So for adding a library to the solution, right-click on the project in the Solution Explorer then select Add -> New Project. Then the New Project screen will be shown. From that screen we will select "Windows" -> "Class Library" and provide this library a meaningful name such as “BusinessLayer”.


2 Answers

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

like image 92
Chase Florell Avatar answered Sep 25 '22 01:09

Chase Florell


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

PM> Install-Package Microsoft.AspNet.Mvc
like image 23
Chuck D Avatar answered Sep 23 '22 01:09

Chuck D