Overriding or injecting code in the Application_Start event in Umbraco can be a little tricky. You have to inherit the Umbraco Application class and override the methods you need. Unless you need to override something specific in the Umbraco pipeline it should be sufficient just to let your startup code run immediately AFTER the Application_Start event.

The WebActivator NuGet package allows us to execute some startup code early in the ASP.NET pipeline. WebActivator was introduced with NuGet to solve the problem of running code without having to add it in the global.asax

Running code after Application_Start

Install the WebActivator package from NuGet


Add a static class to your Visual Studio project. This class will contain your startup code

namespace MyUmbraco.Web
public static class Init
public static void Run()
//Your start up code here

Next wire up your startup code in the AssemblyInfo.cs

using System.Reflection;
using System.Runtime.InteropServices;
using MyUmbraco.Web;
using WebActivatorEx;

[assembly: PostApplicationStartMethod(typeof(Init), "Run")]

Here's a full screenshot of AssemblyInfo.cs


The PostApplicationStartMethod attribute as the name suggests will run your custom startup code After the Application Start event.

Wednesday June 26, 2013, By Anton Pham

comments powered by Disqus

Share this page