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?
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.
精彩评论