diff --git a/src/Microsoft.AspNet.Hosting/HostingServices.cs b/src/Microsoft.AspNet.Hosting/HostingServices.cs index 46b0f947..1a5ac718 100644 --- a/src/Microsoft.AspNet.Hosting/HostingServices.cs +++ b/src/Microsoft.AspNet.Hosting/HostingServices.cs @@ -45,8 +45,13 @@ private class HostingManifest : IServiceManifest public HostingManifest(IServiceProvider fallback) { var manifest = fallback.GetRequiredService(); - Services = new Type[] { typeof(ITypeActivator), typeof(IHostingEnvironment), typeof(ILoggerFactory), typeof(IHttpContextAccessor) } - .Concat(manifest.Services).Distinct(); + Services = new Type[] { + typeof(ITypeActivator), + typeof(IHostingEnvironment), + typeof(ILoggerFactory), + typeof(IHttpContextAccessor), + typeof(IApplicationLifetime) + }.Concat(manifest.Services).Distinct(); } public IEnumerable Services { get; private set; } diff --git a/test/Microsoft.AspNet.Hosting.Tests/UseRequestServicesFacts.cs b/test/Microsoft.AspNet.Hosting.Tests/UseRequestServicesFacts.cs index 44cd34f8..10859e73 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/UseRequestServicesFacts.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/UseRequestServicesFacts.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting.Builder; -using Microsoft.AspNet.Hosting.Server; using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.RequestContainer; using Microsoft.Framework.DependencyInjection; @@ -81,14 +79,11 @@ public void EnsureRequestServicesSetsRequestServices(bool initializeApplicationS } [Theory] - [InlineData(typeof(IHostingEngine))] - [InlineData(typeof(IServerLoader))] - [InlineData(typeof(IApplicationBuilderFactory))] - [InlineData(typeof(IHttpContextFactory))] [InlineData(typeof(ITypeActivator))] - [InlineData(typeof(IApplicationLifetime))] + [InlineData(typeof(IHostingEnvironment))] [InlineData(typeof(ILoggerFactory))] [InlineData(typeof(IHttpContextAccessor))] + [InlineData(typeof(IApplicationLifetime))] public void UseRequestServicesHostingImportedServicesAreDefined(Type service) { var baseServiceProvider = HostingServices.Create().BuildServiceProvider(); @@ -96,7 +91,10 @@ public void UseRequestServicesHostingImportedServicesAreDefined(Type service) builder.UseRequestServices(); - Assert.NotNull(builder.ApplicationServices.GetRequiredService(service)); + var fromAppServices = builder.ApplicationServices.GetRequiredService(service); + + Assert.NotNull(fromAppServices); + Assert.Equal(baseServiceProvider.GetRequiredService(service), fromAppServices); } } } \ No newline at end of file