Pure.Krome
Pure.Krome

Reputation: 86957

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?

Upvotes: 6

Views: 2049

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038830

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.

Upvotes: 2

Related Questions