Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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#" %>
@zpbd
Copy link

zpbd commented Nov 26, 2015

Great, thanks! I needed this to fix Umbraco Forms on my URL rewritten pages by setting Context.Items["IIS_WasUrlRewritten"] = "false"; on BeginRequest

@alikazai
Copy link

alikazai commented Dec 15, 2018

Awesome thanks

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