diff --git a/src/Microsoft.AspNet.Hosting/HostingServices.cs b/src/Microsoft.AspNet.Hosting/HostingServices.cs index 5403f190fb..c7376cd52e 100644 --- a/src/Microsoft.AspNet.Hosting/HostingServices.cs +++ b/src/Microsoft.AspNet.Hosting/HostingServices.cs @@ -59,14 +59,6 @@ namespace Microsoft.AspNet.Hosting Lifecycle = LifecycleKind.Scoped }; - // TODO: Review whether this is the right long term home, and whether Scoped is correct lifetime - yield return new ServiceDescriptor - { - ServiceType = typeof(IOptionsAccessor<>), - ImplementationType = typeof(OptionsAccessor<>), - Lifecycle = LifecycleKind.Scoped - }; - if (PlatformHelper.IsMono) { #if NET45 diff --git a/src/Microsoft.AspNet.RequestContainer/ContainerExtensions.cs b/src/Microsoft.AspNet.RequestContainer/ContainerExtensions.cs index 7db63fe5ff..d2ae5e3619 100644 --- a/src/Microsoft.AspNet.RequestContainer/ContainerExtensions.cs +++ b/src/Microsoft.AspNet.RequestContainer/ContainerExtensions.cs @@ -64,6 +64,15 @@ namespace Microsoft.AspNet.Builder public static IBuilder UseServices(this IBuilder builder, Action configureServices) { var serviceCollection = new ServiceCollection(); + + // TODO: Review whether this is the right long term home, and whether Scoped is correct lifetime + serviceCollection.Add(new ServiceDescriptor + { + ServiceType = typeof(IOptionsAccessor<>), + ImplementationType = typeof(OptionsAccessor<>), + Lifecycle = LifecycleKind.Scoped + }); + configureServices(serviceCollection); builder.ApplicationServices = serviceCollection.BuildServiceProvider(builder.ApplicationServices);