asp.net mvc modular application howto/recommendations

Does anybody have a recommenation for building ASP.Net MVC application in pluggable modular way? I mean some blog-posts/tutorials etc. I just read Hammet's MEF and ASP.NET MVC sample blogpost, but I dont find MEF mature enough to use it in production yet. I wasn't able to google out any other relevant posts on this topic...

I know I could achieve the modularity implementing custom ControllerProvider and some plugin-inspection mechanism, but I'd like to study some more approaches/best practices before I start to reimplement the wheel :)


The modularity I mean by this topic should cover just the web application point of view - nothing other like modular app model/services etc. I'd like to find best possible method to separate one web app into multiple assemblies which would contain additional controllers, views, resources, JS+CSS files, images etc. So there should be some main web app project which would look for available pluggable web app assemblies, load them, publish their controllers, make their views and other resources available and probably prepare some menu with entry for each web app module.

I don't want to discuss any model+services pluggable architecture here - just the ASP.Net M VC part.


Modularity is quite a broad concept, and I think that the answer to your question just has to be subjective. What you are asking about is an architectural decision, and there is no one good way to go about it. Depending on the project, you may have different priorities and importance of different parts of the system. I think that the MVC pattern provides enough separation of concerns, which is actually the purpose of each modular architecture.

If you want to be able to plug a new modules easily in the existing application, then how do you define a module? I think you should narrow down the question a bit to get some non-vague and meaningful answers.


The support for partial-requests to render 3rd part controllers is fully supported in the MVC, take a look at this post: http://blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc/

Obviously, a module in a MVC would contain at least a Controller and one or several Views. But perhaps what you wanted is only the few, and thus it's much easier to rewrite the controller, than if it was traditional WebForms architecture.

Or perhaps you want to replace the data source, simply override the methods in the Model entity, and you're up and running. It's the whole core principal in MVC, that you seperate the different tiers of logic, and that you're FORCED to do it, unlike WebForms that still allows you to do SQL directly in your view if you link.

(That MVC also supports it is not by design, but by inheritance.)


MVC Portable Areas可以很好地解决这个问题

链接地址: http://www.djcxy.com/p/29148.html

上一篇: 实体框架和SQL Server视图

下一篇: asp.net mvc模块化应用程序howto /建议