Staging module in customised environments

When you use the staging module you definitelly have to watch out for some cases. One of the main problems is that when you change the global.asax the module really is going to dislike you.
You’ll receive lots of errors in the logfile. But you can’t do anything which really affect those lines of crap.
Well here’s your handyman!

Most of the time you forgot put this in your global.asax or global.asax.cs:
///------------------------------------------------------------------------
///

Custom error handling

///------------------------------------------------------------------------
protected void Application_Error(Object sender, EventArgs e) {
// Server.Transfer("UnhandledException.aspx");
}

///------------------------------------------------------------------------
///

Shutdown logging

///------------------------------------------------------------------------
public void Application_End() {
Sitecore.Web.HttpModule.OnApplicationEnd();
}

I guess this is applies to all Sitecore functionality. When you override some stuff, don’t forget to copy the original calls.