One of the interesting side-effects of installing ASP.NET MVC 3 is the appearance of Microsoft.Web.Infrastructure in the GAC. Inside the assembly is a DynamicModuleUtility class that will let you do the following:
using System; using System.Web; using Microsoft.Web.Infrastructure.DynamicModuleHelper; [assembly:PreApplicationStartMethod(typeof(MyAppStart), "Start")] public class CoolModule : IHttpModule { // implementation not important // imagine something cool here } public static class MyAppStart { public static void Start() { DynamicModuleUtility.RegisterModule(typeof(CoolModule)); } }
The significant line of code is the line with RegisterModule. The DynamicModuleUtility will let you install an HTTP module into the ASP.NET pipeline without making any changes to web.config file. Registration must occur during the pre application startup up phase, so you'll probably mix dynamic modules with WebActivator for maximum flexibility. The ability to dynamically register modules opens up some interesting options for plugins and infrastructure libraries.