Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created January 12, 2015 04:20
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save csharpforevermore/7bafb204eb5eb093833a to your computer and use it in GitHub Desktop.
Save csharpforevermore/7bafb204eb5eb093833a to your computer and use it in GitHub Desktop.
Custom Global.asax.cs for Umbraco 7
public class CustomGlobal : UmbracoApplication
{
public void Init(HttpApplication application)
{
application.PreRequestHandlerExecute += application_PreRequestHandlerExecute;
application.BeginRequest += this.Application_BeginRequest;
application.EndRequest += this.Application_EndRequest;
application.Error += Application_Error;
}
protected override void OnApplicationStarted(object sender, EventArgs e)
{
base.OnApplicationStarted(sender, e);
// Your code here
}
private void application_PreRequestHandlerExecute(object sender, EventArgs e)
{
try
{
if (Session != null && Session.IsNewSession)
{
// Your code here
}
}
catch (Exception ex) { }
}
private void Application_BeginRequest(object sender, EventArgs e)
{
try
{
// You begin request code here
}
catch { }
}
private void Application_EndRequest(object sender, EventArgs e)
{
// Your code here
}
protected new void Application_Error(object sender, EventArgs e)
{
// Your error handling here
}
}
<%@ Application Codebehind="Global.asax.cs" Inherits="CustomGlobal" Language="C#" %>
@alikazai
Copy link

Awesome thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment