I added a sample of a Asp.Net MVC based framework a web site composed of individually deployable packages.

As you may know the Spark view engine site is a Drupal CMS. I’ve been amazed how well Drupal and WordPress can compose a site from extensions and plugins. There was an earlier question about how you would do that with Spark, so I recently posted a more complete sample following up on that. The code for the sample is in the .zip download under Samples/Modularity/Modularity.sln.

I don’t know why but this was something I really enjoyed doing and the parts really clicked as it came together. The idea is this - there are a number of things in an MVC application that can be loosely associated with each other because they’re powering an area of a site. Let’s say there’s a route to some controllers, and their views, and resources that are only used on those views. Let’s also say there are some services the controllers use.

Loose Objects

Loose Objects

There are a few real-world situations you might want to independently version and deploy this set. You could be making an open source platform designed to be plug-in extensible. Or you could be working on a very large production web site where it’s impractical (even dangerous) to atomically version and deploy the entire width and depth of a multi-team / multi-departmental site.

With a creative use of embedded resources you can compile all of this into an assembly. This example adds the idea of a class that implements IWebPackage which is called by the host for the package to register is component parts. Include a nice Inversion of Control container and packages can also expose and consume services.

Packaged objects in assembly

Packaged objects in assembly

The SendMailService would probably not be in Store.dll - rather those controllers could expect an ISendMail service to be magically dropped in it’s hands and that service could be implemented in any other package which registers an appropriate component.

The ultimate goal is to have a thin shell of a web application project that has little or no capabilities on it’s own, but which will load all of the packages it can discover. Those packages each contribute routes, controllers, services, views, and other reusable partial views.

Packages and assembly references

Packages and assembly references

It sounds impractical and looks like white-board software - but with a combination of Asp.Net MVC, Spark, and the Windsor container it really works well and strikes me as a simple and practical basis for a site architecture.

Call me crazy - but I really have the urge to write a CMS now. Like a dotnet Drupal clone. Too many things are going on to start that soon but unless I come to my senses I might start a CMS project on Codeplex eventually.