diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index e5dc8240a7..419f9cd873 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -187,6 +187,9 @@ namespace Umbraco.Core
///
protected virtual void InitializeResolvers()
{
+ //By default we'll initialize the Log profiler (in the web project, we'll override with the web profiler)
+ ProfilerResolver.Current = new ProfilerResolver(new LogProfiler());
+
//by default we'll use the standard configuration based sync
ServerRegistrarResolver.Current = new ServerRegistrarResolver(
new ConfigServerRegistrar());
diff --git a/src/Umbraco.Core/Profiling/IProfiler.cs b/src/Umbraco.Core/Profiling/IProfiler.cs
index 12e6e6714f..720c71b555 100644
--- a/src/Umbraco.Core/Profiling/IProfiler.cs
+++ b/src/Umbraco.Core/Profiling/IProfiler.cs
@@ -1,44 +1,44 @@
-//using System;
+using System;
-//namespace Umbraco.Core.Profiling
-//{
-// ///
-// /// Defines an object for use in the application to profile operations
-// ///
-// public interface IProfiler
-// {
-
-// ///
-// /// Render the UI to display the profiler
-// ///
-// ///
-// ///
-// /// Generally used for HTML displays
-// ///
-// string Render();
+namespace Umbraco.Core.Profiling
+{
+ ///
+ /// Defines an object for use in the application to profile operations
+ ///
+ internal interface IProfiler
+ {
-// ///
-// /// Profile a step
-// ///
-// ///
-// ///
-// ///
-// /// Use the 'using(' syntax
-// ///
-// IDisposable Step(string name);
+ ///
+ /// Render the UI to display the profiler
+ ///
+ ///
+ ///
+ /// Generally used for HTML displays
+ ///
+ string Render();
-// ///
-// /// Start the profiler
-// ///
-// void Start();
+ ///
+ /// Profile a step
+ ///
+ ///
+ ///
+ ///
+ /// Use the 'using(' syntax
+ ///
+ IDisposable Step(string name);
-// ///
-// /// Start the profiler
-// ///
-// ///
-// /// set discardResults to false when you want to abandon all profiling, this is useful for
-// /// when someone is not authenticated or you want to clear the results based on some other mechanism.
-// ///
-// void Stop(bool discardResults = false);
-// }
-//}
\ No newline at end of file
+ ///
+ /// Start the profiler
+ ///
+ void Start();
+
+ ///
+ /// Start the profiler
+ ///
+ ///
+ /// set discardResults to false when you want to abandon all profiling, this is useful for
+ /// when someone is not authenticated or you want to clear the results based on some other mechanism.
+ ///
+ void Stop(bool discardResults = false);
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Profiling/LogProfiler.cs b/src/Umbraco.Core/Profiling/LogProfiler.cs
index 22b35f4de5..fbcb21988a 100644
--- a/src/Umbraco.Core/Profiling/LogProfiler.cs
+++ b/src/Umbraco.Core/Profiling/LogProfiler.cs
@@ -1,35 +1,35 @@
-//using System;
-//using System.Collections.Generic;
-//using System.Linq;
-//using System.Text;
-//using Umbraco.Core.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Umbraco.Core.Logging;
-//namespace Umbraco.Core.Profiling
-//{
-// ///
-// /// A profiler that outputs its results to the LogHelper
-// ///
-// public class LogProfiler : IProfiler
-// {
-// public string Render()
-// {
-// return string.Empty;
-// }
+namespace Umbraco.Core.Profiling
+{
+ ///
+ /// A profiler that outputs its results to the LogHelper
+ ///
+ internal class LogProfiler : IProfiler
+ {
+ public string Render()
+ {
+ return string.Empty;
+ }
-// public IDisposable Step(string name)
-// {
-// LogHelper.Debug(typeof(LogProfiler), "Starting - " + name);
-// return DisposableTimer.Start(l => LogHelper.Info(typeof (LogProfiler), () => name + " (took " + l + "ms)"));
-// }
+ public IDisposable Step(string name)
+ {
+ LogHelper.Debug(typeof(LogProfiler), "Starting - " + name);
+ return DisposableTimer.Start(l => LogHelper.Info(typeof(LogProfiler), () => name + " (took " + l + "ms)"));
+ }
-// public void Start()
-// {
-// //the log will alwasy be started
-// }
+ public void Start()
+ {
+ //the log will alwasy be started
+ }
-// public void Stop(bool discardResults = false)
-// {
-// //we don't need to do anything here
-// }
-// }
-//}
+ public void Stop(bool discardResults = false)
+ {
+ //we don't need to do anything here
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Profiling/MiniProfilerExtensions.cs b/src/Umbraco.Core/Profiling/ProfilerExtensions.cs
similarity index 56%
rename from src/Umbraco.Core/Profiling/MiniProfilerExtensions.cs
rename to src/Umbraco.Core/Profiling/ProfilerExtensions.cs
index 8eb8a2ba63..16b8ab3e96 100644
--- a/src/Umbraco.Core/Profiling/MiniProfilerExtensions.cs
+++ b/src/Umbraco.Core/Profiling/ProfilerExtensions.cs
@@ -1,9 +1,8 @@
using System;
-using StackExchange.Profiling;
namespace Umbraco.Core.Profiling
{
- public static class MiniProfilerExtensions
+ internal static class ProfilerExtensions
{
///
/// Writes out a step prefixed with the type
@@ -12,9 +11,9 @@ namespace Umbraco.Core.Profiling
///
///
///
- public static IDisposable Step(this MiniProfiler profiler, string name)
+ internal static IDisposable Step(this IProfiler profiler, string name)
{
- return profiler.Step(string.Format("[" + typeof (T).Name + "] " + name));
+ return profiler.Step(string.Format(typeof(T).Name + ", " + name));
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Profiling/ProfilerResolver.cs b/src/Umbraco.Core/Profiling/ProfilerResolver.cs
index 92009967f2..82374a298d 100644
--- a/src/Umbraco.Core/Profiling/ProfilerResolver.cs
+++ b/src/Umbraco.Core/Profiling/ProfilerResolver.cs
@@ -1,37 +1,37 @@
-//using Umbraco.Core.ObjectResolution;
+using Umbraco.Core.ObjectResolution;
-//namespace Umbraco.Core.Profiling
-//{
-// ///
-// /// A resolver exposing the current profiler
-// ///
-// public class ProfilerResolver : SingleObjectResolverBase
-// {
-// ///
-// /// Constructor
-// ///
-// ///
-// public ProfilerResolver(IProfiler profiler)
-// : base(profiler)
-// {
-
-// }
+namespace Umbraco.Core.Profiling
+{
+ ///
+ /// A resolver exposing the current profiler
+ ///
+ internal class ProfilerResolver : SingleObjectResolverBase
+ {
+ ///
+ /// Constructor
+ ///
+ ///
+ public ProfilerResolver(IProfiler profiler)
+ : base(profiler)
+ {
-// ///
-// /// Method allowing to change the profiler during startup
-// ///
-// ///
-// internal void SetProfiler(IProfiler profiler)
-// {
-// Value = profiler;
-// }
+ }
-// ///
-// /// Gets the current profiler
-// ///
-// public IProfiler Profiler
-// {
-// get { return Value; }
-// }
-// }
-//}
\ No newline at end of file
+ ///
+ /// Method allowing to change the profiler during startup
+ ///
+ ///
+ internal void SetProfiler(IProfiler profiler)
+ {
+ Value = profiler;
+ }
+
+ ///
+ /// Gets the current profiler
+ ///
+ public IProfiler Profiler
+ {
+ get { return Value; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Profiling/WebProfiler.cs b/src/Umbraco.Core/Profiling/WebProfiler.cs
index 1c1d40cd45..56918ff349 100644
--- a/src/Umbraco.Core/Profiling/WebProfiler.cs
+++ b/src/Umbraco.Core/Profiling/WebProfiler.cs
@@ -1,161 +1,161 @@
-//using System;
-//using System.Web;
-//using StackExchange.Profiling;
-//using Umbraco.Core.Configuration;
-//using Umbraco.Core.Logging;
+using System;
+using System.Web;
+using StackExchange.Profiling;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
-//namespace Umbraco.Core.Profiling
-//{
-// ///
-// /// A profiler used for web based activity based on the MiniProfiler framework
-// ///
-// public class WebProfiler : IProfiler
-// {
+namespace Umbraco.Core.Profiling
+{
+ ///
+ /// A profiler used for web based activity based on the MiniProfiler framework
+ ///
+ internal class WebProfiler : IProfiler
+ {
-// ///
-// /// Constructor
-// ///
-// ///
-// /// Binds to application events to enable the MiniProfiler
-// ///
-// internal WebProfiler()
-// {
-// UmbracoApplicationBase.ApplicationInit += UmbracoApplicationApplicationInit;
-// }
+ ///
+ /// Constructor
+ ///
+ ///
+ /// Binds to application events to enable the MiniProfiler
+ ///
+ internal WebProfiler()
+ {
+ UmbracoApplicationBase.ApplicationInit += UmbracoApplicationApplicationInit;
+ }
-// ///
-// /// Handle the Init event o fthe UmbracoApplication which allows us to subscribe to the HttpApplication events
-// ///
-// ///
-// ///
-// void UmbracoApplicationApplicationInit(object sender, EventArgs e)
-// {
-// var app = sender as HttpApplication;
-// if (app == null) return;
+ ///
+ /// Handle the Init event o fthe UmbracoApplication which allows us to subscribe to the HttpApplication events
+ ///
+ ///
+ ///
+ void UmbracoApplicationApplicationInit(object sender, EventArgs e)
+ {
+ var app = sender as HttpApplication;
+ if (app == null) return;
-// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
-// {
-// //If we don't have a high enough trust level we cannot bind to the events
-// LogHelper.Info("Cannot start the WebProfiler since the application is running in Medium trust");
-// }
-// else
-// {
-// app.BeginRequest += UmbracoApplicationBeginRequest;
-// app.EndRequest += UmbracoApplicationEndRequest;
-// }
-// }
+ if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
+ {
+ //If we don't have a high enough trust level we cannot bind to the events
+ LogHelper.Info("Cannot start the WebProfiler since the application is running in Medium trust");
+ }
+ else
+ {
+ app.BeginRequest += UmbracoApplicationBeginRequest;
+ app.EndRequest += UmbracoApplicationEndRequest;
+ }
+ }
-// ///
-// /// Handle the begin request event
-// ///
-// ///
-// ///
-// void UmbracoApplicationEndRequest(object sender, EventArgs e)
-// {
-// if (GlobalSettings.DebugMode == false) return;
-// var request = TryGetRequest(sender);
-// if (request.Success == false) return;
-// if (request.Result.Url.IsClientSideRequest()) return;
-// if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
-// {
-// //stop the profiler
-// Stop();
-// }
-// }
+ ///
+ /// Handle the begin request event
+ ///
+ ///
+ ///
+ void UmbracoApplicationEndRequest(object sender, EventArgs e)
+ {
+ if (GlobalSettings.DebugMode == false) return;
+ var request = TryGetRequest(sender);
+ if (request.Success == false) return;
+ if (request.Result.Url.IsClientSideRequest()) return;
+ if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
+ {
+ //stop the profiler
+ Stop();
+ }
+ }
-// ///
-// /// Handle the end request event
-// ///
-// ///
-// ///
-// void UmbracoApplicationBeginRequest(object sender, EventArgs e)
-// {
-// if (GlobalSettings.DebugMode == false) return;
-// var request = TryGetRequest(sender);
-// if (request.Success == false) return;
-// if (request.Result.Url.IsClientSideRequest()) return;
-// if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
-// {
-// //start the profiler
-// Start();
-// }
-// }
+ ///
+ /// Handle the end request event
+ ///
+ ///
+ ///
+ void UmbracoApplicationBeginRequest(object sender, EventArgs e)
+ {
+ if (GlobalSettings.DebugMode == false) return;
+ var request = TryGetRequest(sender);
+ if (request.Success == false) return;
+ if (request.Result.Url.IsClientSideRequest()) return;
+ if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
+ {
+ //start the profiler
+ Start();
+ }
+ }
-// ///
-// /// Render the UI to display the profiler
-// ///
-// ///
-// ///
-// /// Generally used for HTML displays
-// ///
-// public string Render()
-// {
-// return MiniProfiler.RenderIncludes().ToString();
-// }
+ ///
+ /// Render the UI to display the profiler
+ ///
+ ///
+ ///
+ /// Generally used for HTML displays
+ ///
+ public string Render()
+ {
+ return MiniProfiler.RenderIncludes().ToString();
+ }
-// ///
-// /// Profile a step
-// ///
-// ///
-// ///
-// ///
-// /// Use the 'using(' syntax
-// ///
-// public IDisposable Step(string name)
-// {
-// if (GlobalSettings.DebugMode == false) return null;
+ ///
+ /// Profile a step
+ ///
+ ///
+ ///
+ ///
+ /// Use the 'using(' syntax
+ ///
+ public IDisposable Step(string name)
+ {
+ if (GlobalSettings.DebugMode == false) return null;
-// return MiniProfiler.Current.Step(name);
-// }
+ return MiniProfiler.Current.Step(name);
+ }
-// ///
-// /// Start the profiler
-// ///
-// public void Start()
-// {
-// if (GlobalSettings.DebugMode == false) return;
-// //will not run in medium trust
-// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
+ ///
+ /// Start the profiler
+ ///
+ public void Start()
+ {
+ if (GlobalSettings.DebugMode == false) return;
+ //will not run in medium trust
+ if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
-// MiniProfiler.Start();
-// }
+ MiniProfiler.Start();
+ }
-// ///
-// /// Start the profiler
-// ///
-// ///
-// /// set discardResults to false when you want to abandon all profiling, this is useful for
-// /// when someone is not authenticated or you want to clear the results based on some other mechanism.
-// ///
-// public void Stop(bool discardResults = false)
-// {
-// if (GlobalSettings.DebugMode == false) return;
-// //will not run in medium trust
-// if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
+ ///
+ /// Start the profiler
+ ///
+ ///
+ /// set discardResults to false when you want to abandon all profiling, this is useful for
+ /// when someone is not authenticated or you want to clear the results based on some other mechanism.
+ ///
+ public void Stop(bool discardResults = false)
+ {
+ if (GlobalSettings.DebugMode == false) return;
+ //will not run in medium trust
+ if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
-// MiniProfiler.Stop(discardResults);
-// }
+ MiniProfiler.Stop(discardResults);
+ }
-// ///
-// /// Gets the request object from the app instance if it is available
-// ///
-// /// The application object
-// ///
-// private Attempt TryGetRequest(object sender)
-// {
-// var app = sender as HttpApplication;
-// if (app == null) return Attempt.False;
+ ///
+ /// Gets the request object from the app instance if it is available
+ ///
+ /// The application object
+ ///
+ private Attempt TryGetRequest(object sender)
+ {
+ var app = sender as HttpApplication;
+ if (app == null) return Attempt.False;
-// try
-// {
-// var req = app.Request;
-// return new Attempt(true, new HttpRequestWrapper(req));
-// }
-// catch (HttpException ex)
-// {
-// return new Attempt(ex);
-// }
-// }
+ try
+ {
+ var req = app.Request;
+ return new Attempt(true, new HttpRequestWrapper(req));
+ }
+ catch (HttpException ex)
+ {
+ return new Attempt(ex);
+ }
+ }
-// }
-//}
\ No newline at end of file
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 6f23a9f69e..7ba29b88d2 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -525,7 +525,7 @@
-
+
diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs
index 8cedd54bc9..eef1aa2215 100644
--- a/src/Umbraco.Core/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Core/UmbracoApplicationBase.cs
@@ -25,6 +25,11 @@ namespace Umbraco.Core
public static event EventHandler ApplicationStarting;
public static event EventHandler ApplicationStarted;
+ ///
+ /// Called when the HttpApplication.Init() is fired, allows developers to subscribe to the HttpApplication events
+ ///
+ public static event EventHandler ApplicationInit;
+
///
/// Boots up the Umbraco application
///
@@ -48,49 +53,17 @@ namespace Umbraco.Core
protected void Application_Start(object sender, EventArgs e)
{
StartApplication(sender, e);
-
- if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
- {
- //If we don't have a high enough trust level we cannot bind to the events
- LogHelper.Info("Cannot use the MiniProfiler since the application is running in Medium trust");
- }
}
///
- /// Initializes the mini profiler for the request
+ /// Override init and raise the event
///
- protected void Application_BeginRequest()
+ public override void Init()
{
- if (GlobalSettings.DebugMode == false) return;
- var request = TryGetRequest();
- if (request.Success == false) return;
- if (request.Result.Url.IsClientSideRequest()) return;
- if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
- if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
- {
- //start the profiler
- MiniProfiler.Start();
- }
+ base.Init();
+ OnApplicationInit(this, new EventArgs());
}
- ///
- /// Closes the mini profiler for the request
- ///
- protected void Application_EndRequest()
- {
- if (GlobalSettings.DebugMode == false) return;
- var request = TryGetRequest();
- if (request.Success == false) return;
- if (request.Result.Url.IsClientSideRequest()) return;
- if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
- if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
- {
- //stop the profiler
- MiniProfiler.Stop();
- }
- }
-
-
///
/// Developers can override this method to modify objects on startup
///
@@ -112,7 +85,18 @@ namespace Umbraco.Core
if (ApplicationStarted != null)
ApplicationStarted(sender, e);
}
-
+
+ ///
+ /// Called to raise the ApplicationInit event
+ ///
+ ///
+ ///
+ private void OnApplicationInit(object sender, EventArgs e)
+ {
+ if (ApplicationInit != null)
+ ApplicationInit(sender, e);
+ }
+
///
/// A method that can be overridden to invoke code when the application has an error.
///
@@ -162,22 +146,5 @@ namespace Umbraco.Core
protected abstract IBootManager GetBootManager();
- ///
- /// Gets the request object from the app instance if it is available
- ///
- ///
- private Attempt TryGetRequest()
- {
- try
- {
- var req = Request;
- return new Attempt(true, new HttpRequestWrapper(req));
- }
- catch (HttpException ex)
- {
- return new Attempt(ex);
- }
- }
-
}
}
diff --git a/src/Umbraco.Web.UI/umbraco/umbraco.aspx b/src/Umbraco.Web.UI/umbraco/umbraco.aspx
index 4a9490b049..6f6ec216e9 100644
--- a/src/Umbraco.Web.UI/umbraco/umbraco.aspx
+++ b/src/Umbraco.Web.UI/umbraco/umbraco.aspx
@@ -6,6 +6,7 @@
<%@ Register Src="controls/Tree/TreeControl.ascx" TagName="TreeControl" TagPrefix="umbraco" %>
<%@ Import Namespace="StackExchange.Profiling" %>
<%@ Import Namespace="Umbraco.Core.Profiling" %>
+<%@ Import Namespace="Umbraco.Web" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="uc1" TagName="quickSearch" Src="Search/QuickSearch.ascx" %>
<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
@@ -392,7 +393,7 @@
<%if(string.IsNullOrEmpty(Request["umbDebug"]) == false && umbraco.GlobalSettings.DebugMode)
{
- Response.Write(MiniProfiler.RenderIncludes());
+ Response.Write(Html.RenderProfiler());
}%>