Try our conversational search powered by Generative AI!

Per Bjurström
Jan 27, 2011
  7687
(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 and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog