Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an ASP.NET MVC3 Controller (and View?) be redistributed as a class library dll?

is it possible to add a single Controller and possibly a view or two, in a class library ... which could then be redistributed (ie. via NuGet) and reused in various applications?

I'm thinking of providing a default view (or two) but allowing the consumer to override this view via a public property.

Possible?

like image 691
Pure.Krome Avatar asked Feb 27 '11 10:02

Pure.Krome


People also ask

Is ASP.NET MVC discontinued?

ASP.NET MVC is no longer in active development.

Can we use ASP NET controls in MVC?

In ASP.Net you need to register one tagprefix and then use the user control by tagprefix registered but in ASP.Net MVC using simple Thml. RenderPartial we can use the user control.

What are the 3 main components of an ASP.NET MVC application?

The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.

Which of the following is a base class for creating MVC controller without view support?

ControllerBase : A base class for an MVC controller without view support.


1 Answers

There is nothing built-in ASP.NET MVC 3 allowing you to embed views into class libraries (controllers, yes, but not views). It is necessary to write a custom VirtualPathProvider. Here's a blog post which might put you on the right track. And you could also take a look at MVCContrib portable areas which allows you to do this.

like image 77
Darin Dimitrov Avatar answered Sep 30 '22 03:09

Darin Dimitrov