Created
January 12, 2015 04:20
-
-
Save csharpforevermore/7bafb204eb5eb093833a to your computer and use it in GitHub Desktop.
Custom Global.asax.cs for Umbraco 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Application Codebehind="Global.asax.cs" Inherits="CustomGlobal" Language="C#" %> |
Great, thanks! I needed this to fix Umbraco Forms on my URL rewritten pages by setting Context.Items["IIS_WasUrlRewritten"] = "false";
on BeginRequest
Awesome thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, just what I needed!