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.
Comments
I can't find the Microsoft.Web.Infrastructure assembly nowhere. It isn't in the GAC, the Program Files\Microsoft ASP.NET\ASP.NET MVC 3 folder and it isn't in the source files at CodePlex!
Thanks,
RP
Thanks for your quick reply! Indeed, they are installed with MVC 3, I just hadn't noticed this folder. Thanks for the post and the information!:-)
RP
You know if it's possible to use this type of implementation to load assemblies into a new AppDomain to not restart the application?
K
could use stuff inside of System.AddIn to do.
PS : great courses you have at Plural Sight. The only thing missing is how to go from VS 2010 dev environment to production environment concerning Entity Framework Code First.
That should be available soon (a deployment module).