diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/DefaultControllerActivator.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/DefaultControllerActivator.cs
index 25493affb4..fc35b6286d 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/DefaultControllerActivator.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/DefaultControllerActivator.cs
@@ -2,6 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Reflection;
+using Microsoft.AspNetCore.Mvc.Core;
+using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
namespace Microsoft.AspNetCore.Mvc.Controllers
@@ -19,23 +22,64 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
/// The .
public DefaultControllerActivator(ITypeActivatorCache typeActivatorCache)
{
+ if (typeActivatorCache == null)
+ {
+ throw new ArgumentNullException(nameof(typeActivatorCache));
+ }
+
_typeActivatorCache = typeActivatorCache;
}
+
///
- public virtual object Create(ActionContext actionContext, Type controllerType)
+ public virtual object Create(ControllerContext controllerContext)
{
- if (actionContext == null)
+ if (controllerContext == null)
{
- throw new ArgumentNullException(nameof(actionContext));
+ throw new ArgumentNullException(nameof(controllerContext));
}
- if (controllerType == null)
+ if (controllerContext.ActionDescriptor == null)
{
- throw new ArgumentNullException(nameof(controllerType));
+ throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull(
+ nameof(ControllerContext.ActionDescriptor),
+ nameof(ControllerContext)));
}
- var serviceProvider = actionContext.HttpContext.RequestServices;
- return _typeActivatorCache.CreateInstance