Skip to content

Instantly share code, notes, and snippets.

@jglozano
Created July 9, 2011 16:28
Show Gist options
  • Save jglozano/1073711 to your computer and use it in GitHub Desktop.
Save jglozano/1073711 to your computer and use it in GitHub Desktop.
HttpModule Manual Registration
public class MvcApplication : MvcTurbine.Web.TurbineApplication {
static MvcApplication() {
// Specify the CSL to use
ServiceLocatorManager.SetLocatorProvider(() => new NinjectServiceLocator());
// Remove auto-registration for all IHttpModules
Engine.Initialize
.DisableHttpModuleRegistration();
}
}
// This class provides metadata for IHttpModule registration
public class CustomHttpRegistry : HttpModuleRegistry {
public CustomHttpRegistry() {
// Adds the specified module
Add<MyModule>()
// Adds the specified module with the given name
Add<MyModule>("myModule");
}
}
// Custom IHttpModule
public class MyModule : IHttpModule {
public void Init(HttpApplication context) {
context.BeginRequest += context_BeginRequest;
}
void context_BeginRequest(object sender, EventArgs e) {
// Complex code goes here
}
public void Dispose() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment