views:

1033

answers:

6

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.

+2  A: 

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.

Slavo
you're right - I tried to edit the post to narrow the topic down..
Buthrakaur
A: 

The basic arguments for modularity are always the same...

  • Testability
  • Maintainability
  • Ease of deployment
Sohnee
+1  A: 

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.)

Claus Jørgensen
A: 

Hi I have same question. How i cant develop a modular framework/CMS with ASP.Net MVC? Is it good? or you know better solution? thanks for all answers and at first for questioner. Ray.

Ray
A: 

As a starting point, you could grab some ideas from this article:

Spark View Engine - Modularity

And the sample code:

spark / src / Samples / Modules

The code is in the Spark View Engine tree (which is a very nice and powerful project) but doesn't have much to do with it. It uses Castle to build up dependencies and all that stuff.

By the way, I've been messing with MEF but I don't really see the benefits right now and the things I needed to do can be done with Castle and some tooling (helpers to query assemblies and things like that).

Marc Climent
A: 

Hi Buthrakaur (and everybody else)

Do you have any recommendations or have you found any ressources (not mentioned here) discussing this subject matter?

I'm about to start an asp.net mvc project, where modularity in the UI is of great significance.

DerDres