开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜