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

2k Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

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.