The recommended approach is not to modify the Global.asax file of the host application. Instead, you can use WebActivator and add a separate file to the project. Take a look, for example, at Ninject.MVC3 NuGet, which does just that.
For example, when you install your NuGet, you can simply add the following file ~/App_Start/MyNuGetAppStart.cs :
[assembly: WebActivator.PreApplicationStartMethod(typeof(SomeNamespace.AppStart), "Start")] namespace SomeNamespace { public static class AppStart {
This is a much more unobtrusive way to add custom code when the application starts, rather than messing around with the Global.asax file that the user may already have configured.
Darin Dimitrov
source share