using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Web.Routing;
using umbraco.businesslogic;
namespace Umbraco.Web
{
///
/// The Umbraco global.asax class
///
public class UmbracoApplication : System.Web.HttpApplication
{
public UmbracoApplication()
{
_bootManager = new WebBootManager(this);
}
private readonly IBootManager _bootManager;
public static event EventHandler ApplicationStarting;
public static event EventHandler ApplicationStarted;
///
/// Initializes the Umbraco application
///
///
///
protected void Application_Start(object sender, EventArgs e)
{
//boot up the application
_bootManager
.Initialize()
.Startup(appContext => OnApplicationStarting(sender, e))
.Complete(appContext => OnApplicationStarted(sender, e));
}
///
/// Developers can override this method to modify objects on startup
///
///
///
protected virtual void OnApplicationStarting(object sender, EventArgs e)
{
if (ApplicationStarting != null)
ApplicationStarting(sender, e);
}
///
/// Developers can override this method to do anything they need to do once the application startup routine is completed.
///
///
///
protected virtual void OnApplicationStarted(object sender, EventArgs e)
{
if (ApplicationStarted != null)
ApplicationStarted(sender, e);
}
///
/// A method that can be overridden to invoke code when the application has an error.
///
///
///
protected virtual void OnApplicationError(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
OnApplicationError(sender, e);
}
///
/// A method that can be overridden to invoke code when the application shuts down.
///
///
///
protected virtual void OnApplicationEnd(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
if (SystemUtilities.GetCurrentTrustLevel() == AspNetHostingPermissionLevel.Unrestricted)
{
LogHelper.Info("Application shutdown. Reason: " + HostingEnvironment.ShutdownReason);
}
OnApplicationEnd(sender, e);
}
}
}