diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs index 294465f192..1546fb8c51 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerFactory.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Reflection; -using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.DependencyInjection; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Rendering; @@ -29,7 +28,7 @@ namespace Microsoft.AspNet.Mvc try { - var controller = _activator.CreateInstance(actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType()); + var controller = _activator.CreateInstance(_serviceProvider, actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType()); // TODO: How do we feed the controller with context (need DI improvements) InitializeController(controller, actionContext); diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs index 1e88f41bd9..a9d614e22a 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Binders/GenericModelBinder.cs @@ -10,9 +10,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding public class GenericModelBinder : IModelBinder { private readonly ITypeActivator _activator; + private readonly IServiceProvider _serviceProvider; - public GenericModelBinder(ITypeActivator activator) + public GenericModelBinder(IServiceProvider serviceProvider, ITypeActivator activator) { + _serviceProvider = serviceProvider; _activator = activator; } @@ -21,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding Type binderType = ResolveBinderType(bindingContext.ModelType); if (binderType != null) { - var binder = (IModelBinder)_activator.CreateInstance(binderType); + var binder = (IModelBinder)_activator.CreateInstance(_serviceProvider, binderType); return binder.BindModel(bindingContext); }