diff --git a/DNN Platform/DotNetNuke.Web.Mvc/DnnMvcDependencyResolver.cs b/DNN Platform/DotNetNuke.Web.Mvc/DnnMvcDependencyResolver.cs
index bbd08a99203..d94b09cbf8e 100644
--- a/DNN Platform/DotNetNuke.Web.Mvc/DnnMvcDependencyResolver.cs
+++ b/DNN Platform/DotNetNuke.Web.Mvc/DnnMvcDependencyResolver.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
+using DotNetNuke.Services.DependencyInjection;
namespace DotNetNuke.Web.Mvc
{
@@ -16,18 +17,10 @@ namespace DotNetNuke.Web.Mvc
internal class DnnMvcDependencyResolver : IDependencyResolver
{
private readonly IServiceProvider _serviceProvider;
- private readonly IDependencyResolver _resolver;
- ///
- /// Instantiate a new instance of the .
- ///
- ///
- /// The to be used in the
- ///
- public DnnMvcDependencyResolver(IServiceProvider serviceProvider, IDependencyResolver resolver)
+ public DnnMvcDependencyResolver(IServiceProvider serviceProvider)
{
- _serviceProvider = serviceProvider;
- _resolver = resolver;
+ _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
}
///
@@ -41,14 +34,12 @@ public DnnMvcDependencyResolver(IServiceProvider serviceProvider, IDependencyRes
///
public object GetService(Type serviceType)
{
- try
- {
- return _serviceProvider.GetService(serviceType);
- }
- catch
- {
- return _resolver.GetService(serviceType);
- }
+ var accessor = _serviceProvider.GetRequiredService();
+ var scope = accessor.GetScope();
+ if (scope != null)
+ return scope.ServiceProvider.GetService(serviceType);
+
+ throw new InvalidOperationException("IServiceScope not provided");
}
///
@@ -62,14 +53,12 @@ public object GetService(Type serviceType)
///
public IEnumerable