diff --git a/src/SimpleInjector.Integration.Web.Mvc/SimpleInjectorDependencyResolver.cs b/src/SimpleInjector.Integration.Web.Mvc/SimpleInjectorDependencyResolver.cs index 1f380995f..c741787a3 100644 --- a/src/SimpleInjector.Integration.Web.Mvc/SimpleInjectorDependencyResolver.cs +++ b/src/SimpleInjector.Integration.Web.Mvc/SimpleInjectorDependencyResolver.cs @@ -114,6 +114,8 @@ public IEnumerable GetServices(Type serviceType) var services = (IEnumerable)this.ServiceProvider.GetService(collectionType); + // NOTE: The contract of IDependencyResolver isn't very clear, but MVC will break when null + // is returned. return services ?? Enumerable.Empty(); } } diff --git a/src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiDependencyResolver.cs b/src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiDependencyResolver.cs index f9885ee34..8b90c9ee9 100644 --- a/src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiDependencyResolver.cs +++ b/src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiDependencyResolver.cs @@ -185,6 +185,8 @@ IEnumerable IDependencyScope.GetServices(Type serviceType) var services = (IEnumerable)this.ServiceProvider.GetService(collectionType); + // NOTE: The contract of IDependencyScope isn't very clear, but Web API will break when null + // is returned. return services ?? Enumerable.Empty(); }