diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs
index 225493b57b..bb81c79f2a 100644
--- a/src/Umbraco.Core/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Core/UmbracoApplicationBase.cs
@@ -72,6 +72,11 @@ namespace Umbraco.Core
///
/// Override init and raise the event
///
+ ///
+ /// DID YOU KNOW? The Global.asax Init call is the thing that initializes all of the httpmodules, ties up a bunch of stuff with IIS, etc...
+ /// Therefore, since OWIN is an HttpModule when running in IIS/ASP.Net the OWIN startup is not executed until this method fires and by that
+ /// time, Umbraco has performed it's bootup sequence.
+ ///
public override void Init()
{
base.Init();
diff --git a/src/Umbraco.Web/OwinMiddlewareConfiguredEventArgs.cs b/src/Umbraco.Web/OwinMiddlewareConfiguredEventArgs.cs
new file mode 100644
index 0000000000..03c2dc631d
--- /dev/null
+++ b/src/Umbraco.Web/OwinMiddlewareConfiguredEventArgs.cs
@@ -0,0 +1,15 @@
+using System;
+using Owin;
+
+namespace Umbraco.Web
+{
+ public class OwinMiddlewareConfiguredEventArgs : EventArgs
+ {
+ public OwinMiddlewareConfiguredEventArgs(IAppBuilder appBuilder)
+ {
+ AppBuilder = appBuilder;
+ }
+
+ public IAppBuilder AppBuilder { get; private set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
index 3097407de3..be4c8923d7 100644
--- a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
+++ b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
@@ -24,10 +24,31 @@ namespace Umbraco.Web.Security.Identity
{
public static class AppBuilderExtensions
{
+ ///
+ /// Called at the end of configuring middleware
+ ///
+ ///
+ ///
+ /// This could be used for something else in the future - maybe to inform Umbraco that middleware is done/ready, but for
+ /// now this is used to raise the custom event
+ ///
+ /// This is an extension method in case developer entirely replace the UmbracoDefaultOwinStartup class, in which case they will
+ /// need to ensure they call this extension method in their startup class.
+ ///
+ /// TODO: Move this method in v8, it doesn't belong in this namespace/extension class
+ ///
+ public static void FinalizeMiddlewareConfiguration(this IAppBuilder app)
+ {
+ UmbracoDefaultOwinStartup.OnMiddlewareConfigured(new OwinMiddlewareConfiguredEventArgs(app));
+ }
+
///
/// Sets the OWIN logger to use Umbraco's logging system
///
///
+ ///
+ /// TODO: Move this method in v8, it doesn't belong in this namespace/extension class
+ ///
public static void SetUmbracoLoggerFactory(this IAppBuilder app)
{
app.SetLoggerFactory(new OwinLoggerFactory());
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 35dc036fd3..3aeffcfe16 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -349,6 +349,7 @@
+
diff --git a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
index 5b3fadd0f3..046b2167d5 100644
--- a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
+++ b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
@@ -1,4 +1,5 @@
-using System.Web;
+using System;
+using System.Web;
using Microsoft.Owin;
using Microsoft.Owin.Extensions;
using Microsoft.Owin.Logging;
@@ -59,12 +60,24 @@ namespace Umbraco.Web
app
.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext, PipelineStage.Authenticate)
.UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext, PipelineStage.Authenticate)
- .UseUmbracoPreviewAuthentication(ApplicationContext, PipelineStage.Authorize);
+ .UseUmbracoPreviewAuthentication(ApplicationContext, PipelineStage.Authorize)
+ .FinalizeMiddlewareConfiguration();
}
+ ///
+ /// Raised when the middelware has been configured
+ ///
+ public static event EventHandler MiddlewareConfigured;
+
protected virtual ApplicationContext ApplicationContext
{
get { return ApplicationContext.Current; }
}
+
+ internal static void OnMiddlewareConfigured(OwinMiddlewareConfiguredEventArgs args)
+ {
+ var handler = MiddlewareConfigured;
+ if (handler != null) handler(null, args);
+ }
}
}