diff --git a/src/Umbraco.Core/Composing/IContainer.cs b/src/Umbraco.Core/Composing/IContainer.cs
index 9a5452bf65..2937fb2b02 100644
--- a/src/Umbraco.Core/Composing/IContainer.cs
+++ b/src/Umbraco.Core/Composing/IContainer.cs
@@ -169,5 +169,7 @@ namespace Umbraco.Core.Composing
IContainer EnablePerWebRequestScope();
#endregion
+
+ void Release(object instance);
}
}
diff --git a/src/Umbraco.Core/Composing/LightInject/LightInjectContainer.cs b/src/Umbraco.Core/Composing/LightInject/LightInjectContainer.cs
index 269873a3de..d4b88e862c 100644
--- a/src/Umbraco.Core/Composing/LightInject/LightInjectContainer.cs
+++ b/src/Umbraco.Core/Composing/LightInject/LightInjectContainer.cs
@@ -314,6 +314,11 @@ namespace Umbraco.Core.Composing.LightInject
#endregion
+ public void Release(object instance)
+ {
+ // fixme - no idea how to do this with LI
+ }
+
#region Control
///
diff --git a/src/Umbraco.Web/Mvc/ContainerControllerFactory.cs b/src/Umbraco.Web/Mvc/ContainerControllerFactory.cs
new file mode 100644
index 0000000000..d37054fda1
--- /dev/null
+++ b/src/Umbraco.Web/Mvc/ContainerControllerFactory.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Web.Mvc;
+using System.Web.Routing;
+using System.Web.SessionState;
+using Umbraco.Core.Composing;
+
+namespace Umbraco.Web.Mvc
+{
+ public class ContainerControllerFactory : DefaultControllerFactory
+ {
+ private readonly IContainer container;
+
+ public ContainerControllerFactory(IContainer container)
+ {
+ this.container = container;
+ }
+
+ protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
+ {
+ return (IController)container.GetInstance(controllerType);
+ }
+
+ public override void ReleaseController(IController controller)
+ {
+ container.Release(controller);
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Mvc/MasterControllerFactory.cs b/src/Umbraco.Web/Mvc/MasterControllerFactory.cs
index 20c5c1cfd5..3d1e450c93 100644
--- a/src/Umbraco.Web/Mvc/MasterControllerFactory.cs
+++ b/src/Umbraco.Web/Mvc/MasterControllerFactory.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
+using Umbraco.Web.Composing;
namespace Umbraco.Web.Mvc
{
@@ -11,7 +12,7 @@ namespace Umbraco.Web.Mvc
/// request. Allows circumvention of MVC3's singly registered IControllerFactory.
///
///
- internal class MasterControllerFactory : DefaultControllerFactory
+ internal class MasterControllerFactory : ContainerControllerFactory
{
private readonly Func _factoriesAccessor;
private FilteredControllerFactoryCollection _factories;
@@ -21,6 +22,7 @@ namespace Umbraco.Web.Mvc
///
/// The factories accessor.
public MasterControllerFactory(Func factoriesAccessor)
+ : base(Current.Container)
{
// note
// because the MasterControllerFactory needs to be ctored to be assigned to
diff --git a/src/Umbraco.Web/Mvc/UmbracoControllerFactory.cs b/src/Umbraco.Web/Mvc/UmbracoControllerFactory.cs
index 2c68718ec2..330031976d 100644
--- a/src/Umbraco.Web/Mvc/UmbracoControllerFactory.cs
+++ b/src/Umbraco.Web/Mvc/UmbracoControllerFactory.cs
@@ -65,8 +65,14 @@ namespace Umbraco.Web.Mvc
/// this nested class changes the visibility of 's internal methods in order to not have to rely on a try-catch.
///
///
- internal class OverridenDefaultControllerFactory : DefaultControllerFactory
+ internal class OverridenDefaultControllerFactory : ContainerControllerFactory
+ // DefaultControllerFactory
{
+ public OverridenDefaultControllerFactory()
+ : base(Current.Container)
+ {
+ }
+
public new IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
return base.GetControllerInstance(requestContext, controllerType);
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index cc477c3224..79f0fbdafb 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -116,6 +116,7 @@
+