November Happy Hour will be moved to Thursday December 5th.

Per Bjurström
Jan 27, 2011
  7880
(3 votes)

Initialize HTTP events in a module

EPiServer CMS 6 and Community 4 introduced a new approach to initialization, read more about it here.

We are adding infrastructure for subscribing to HTTP events in the R2 wave with the new IInitializableHttpModule interface which is defined like this:

public interface IInitializableHttpModule : IInitializableModule
{
void InitializeHttpEvents(HttpApplication application);
}

Every time a new HttpApplication is being initialized this interface will let you participate and listen to events. Do remember that this is an initializer interface, there will only be one instance of your initializer but there will be many HttpApplication instances being initialized. The use case for this interface is to able to deploy modules without adding adding an HTTP Module in web.config.

A skeleton module to use the new interface:

[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class MyInitialization : IInitializableHttpModule
{
public void InitializeHttpEvents(HttpApplication application)
{
application.BeginRequest += application_BeginRequest;
}

public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
DataFactory.Instance.PublishedPage += Instance_PublishedPage;
}

public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
DataFactory.Instance.PublishedPage -= Instance_PublishedPage;
}

public void Preload(string[] parameters)
{
}

void Instance_PublishedPage(object sender, PageEventArgs e)
{
//implementation
}

void application_BeginRequest(object sender, EventArgs e)
{
//implementation
}
}

Jan 27, 2011

Comments

Jan 27, 2011 02:14 PM

Nice!
Also: adding adding ;)

Please login to comment.
Latest blogs
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog