Created
July 9, 2011 16:28
-
-
Save jglozano/1073711 to your computer and use it in GitHub Desktop.
HttpModule Manual Registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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