Replace IHostingEnvironment with IWebHostEnvironment (#7725)
This commit is contained in:
parent
7af971838e
commit
4e44025a52
|
|
@ -1,7 +1,7 @@
|
||||||
@using Microsoft.AspNetCore.Hosting
|
@using Microsoft.AspNetCore.Hosting
|
||||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||||
|
|
||||||
@inject IHostingEnvironment Environment
|
@inject IWebHostEnvironment Environment
|
||||||
@inject ICompositeViewEngine Engine
|
@inject ICompositeViewEngine Engine
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
@using Microsoft.AspNetCore.Hosting
|
@using Microsoft.AspNetCore.Hosting
|
||||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||||
|
|
||||||
@inject IHostingEnvironment Environment
|
@inject IWebHostEnvironment Environment
|
||||||
@inject ICompositeViewEngine Engine
|
@inject ICompositeViewEngine Engine
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
@ -14,7 +14,7 @@ namespace AzureAD.WebSite
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Blazor.Cli.Server
|
||||||
|
|
||||||
private static string FindClientAssemblyPath(IApplicationBuilder app)
|
private static string FindClientAssemblyPath(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var env = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
||||||
var contentRoot = env.ContentRootPath;
|
var contentRoot = env.ContentRootPath;
|
||||||
var binDir = FindClientBinDir(contentRoot);
|
var binDir = FindClientBinDir(contentRoot);
|
||||||
var appName = Path.GetFileName(contentRoot); // TODO: Allow for the possibility that the assembly name has been overridden
|
var appName = Path.GetFileName(contentRoot); // TODO: Allow for the possibility that the assembly name has been overridden
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace HostedInAspNet.Server
|
namespace HostedInAspNet.Server
|
||||||
{
|
{
|
||||||
|
|
@ -16,7 +17,7 @@ namespace HostedInAspNet.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
@ -8,7 +8,7 @@ namespace MonoSanity
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true });
|
app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true });
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ using Microsoft.Net.Http.Headers;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Builder
|
namespace Microsoft.AspNetCore.Builder
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +50,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
// TODO: Make the .blazor.config file contents sane
|
// TODO: Make the .blazor.config file contents sane
|
||||||
// Currently the items in it are bizarre and don't relate to their purpose,
|
// Currently the items in it are bizarre and don't relate to their purpose,
|
||||||
// hence all the path manipulation here. We shouldn't be hardcoding 'dist' here either.
|
// hence all the path manipulation here. We shouldn't be hardcoding 'dist' here either.
|
||||||
var env = (IHostingEnvironment)app.ApplicationServices.GetService(typeof(IHostingEnvironment));
|
var env = (IWebHostEnvironment)app.ApplicationServices.GetService(typeof(IWebHostEnvironment));
|
||||||
var config = BlazorConfig.Read(options.ClientAssemblyPath);
|
var config = BlazorConfig.Read(options.ClientAssemblyPath);
|
||||||
|
|
||||||
if (env.IsDevelopment() && config.EnableAutoRebuilding)
|
if (env.IsDevelopment() && config.EnableAutoRebuilding)
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ namespace ComponentsApp.Server
|
||||||
{
|
{
|
||||||
public class DefaultWeatherForecastService : WeatherForecastService
|
public class DefaultWeatherForecastService : WeatherForecastService
|
||||||
{
|
{
|
||||||
private readonly IHostingEnvironment _hostingEnvironment;
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
|
|
||||||
public DefaultWeatherForecastService(IHostingEnvironment hostingEnvironment)
|
public DefaultWeatherForecastService(IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
_hostingEnvironment = hostingEnvironment;
|
_hostingEnvironment = hostingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Components.Server.Circuits;
|
using Microsoft.AspNetCore.Components.Server.Circuits;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
|
||||||
namespace ComponentsApp.Server
|
namespace ComponentsApp.Server
|
||||||
{
|
{
|
||||||
|
|
@ -17,7 +19,7 @@ namespace ComponentsApp.Server
|
||||||
services.AddSingleton<WeatherForecastService, DefaultWeatherForecastService>();
|
services.AddSingleton<WeatherForecastService, DefaultWeatherForecastService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace TestServer
|
namespace TestServer
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +28,7 @@ namespace TestServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.DataProtection.Internal
|
namespace Microsoft.AspNetCore.DataProtection.Internal
|
||||||
{
|
{
|
||||||
internal class HostingApplicationDiscriminator : IApplicationDiscriminator
|
internal class HostingApplicationDiscriminator : IApplicationDiscriminator
|
||||||
{
|
{
|
||||||
private readonly IHostingEnvironment _hosting;
|
private readonly IHostEnvironment _hosting;
|
||||||
|
|
||||||
// the optional constructor for when IHostingEnvironment is not available from DI
|
// the optional constructor for when IHostingEnvironment is not available from DI
|
||||||
public HostingApplicationDiscriminator()
|
public HostingApplicationDiscriminator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostingApplicationDiscriminator(IHostingEnvironment hosting)
|
public HostingApplicationDiscriminator(IHostEnvironment hosting)
|
||||||
{
|
{
|
||||||
_hosting = hosting;
|
_hosting = hosting;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
public void GetApplicationUniqueIdentifierFromHosting(string contentRootPath, string expected)
|
public void GetApplicationUniqueIdentifierFromHosting(string contentRootPath, string expected)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var mockEnvironment = new Mock<IHostingEnvironment>();
|
var mockEnvironment = new Mock<IHostEnvironment>();
|
||||||
mockEnvironment.Setup(o => o.ContentRootPath).Returns(contentRootPath);
|
mockEnvironment.Setup(o => o.ContentRootPath).Returns(contentRootPath);
|
||||||
|
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
|
|
@ -47,7 +48,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
var mockAppDiscriminator = new Mock<IApplicationDiscriminator>();
|
var mockAppDiscriminator = new Mock<IApplicationDiscriminator>();
|
||||||
mockAppDiscriminator.Setup(o => o.Discriminator).Returns(discriminator);
|
mockAppDiscriminator.Setup(o => o.Discriminator).Returns(discriminator);
|
||||||
|
|
||||||
var mockEnvironment = new Mock<IHostingEnvironment>();
|
var mockEnvironment = new Mock<IHostEnvironment>();
|
||||||
mockEnvironment.SetupGet(o => o.ContentRootPath).Throws(new InvalidOperationException("Hosting environment should not be checked"));
|
mockEnvironment.SetupGet(o => o.ContentRootPath).Throws(new InvalidOperationException("Hosting environment should not be checked"));
|
||||||
|
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
@ -15,7 +15,7 @@ namespace SampleApp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Run(async (context) =>
|
app.Run(async (context) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
|
@ -118,9 +119,9 @@ namespace Microsoft.AspNetCore
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
/// set the <see cref="IHostEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostEnvironment.EnvironmentName"/>].json',
|
||||||
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
/// load <see cref="IConfiguration"/> from environment variables,
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
/// and enable IIS integration.
|
/// and enable IIS integration.
|
||||||
|
|
@ -135,9 +136,9 @@ namespace Microsoft.AspNetCore
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
/// set the <see cref="IHostEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostEnvironment.EnvironmentName"/>].json',
|
||||||
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
/// load <see cref="IConfiguration"/> from environment variables,
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
/// load <see cref="IConfiguration"/> from supplied command line args,
|
/// load <see cref="IConfiguration"/> from supplied command line args,
|
||||||
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
|
|
@ -235,9 +236,9 @@ namespace Microsoft.AspNetCore
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||||
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
/// use Kestrel as the web server and configure it using the application's configuration providers,
|
||||||
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
/// set the <see cref="IHostEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
|
||||||
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostingEnvironment.EnvironmentName"/>].json',
|
/// load <see cref="IConfiguration"/> from 'appsettings.json' and 'appsettings.[<see cref="IHostEnvironment.EnvironmentName"/>].json',
|
||||||
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||||
/// load <see cref="IConfiguration"/> from environment variables,
|
/// load <see cref="IConfiguration"/> from environment variables,
|
||||||
/// load <see cref="IConfiguration"/> from supplied command line args,
|
/// load <see cref="IConfiguration"/> from supplied command line args,
|
||||||
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -30,7 +30,7 @@ namespace CreateDefaultBuilderApp
|
||||||
}))
|
}))
|
||||||
.Configure(app => app.Run(context =>
|
.Configure(app => app.Run(context =>
|
||||||
{
|
{
|
||||||
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
||||||
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
||||||
}))
|
}))
|
||||||
.Build().Run();
|
.Build().Run();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.HostFiltering;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace CreateDefaultBuilderOfTApp
|
namespace CreateDefaultBuilderOfTApp
|
||||||
|
|
@ -40,7 +41,7 @@ namespace CreateDefaultBuilderOfTApp
|
||||||
responseMessage = "AllowedHosts not loaded into Options.";
|
responseMessage = "AllowedHosts not loaded into Options.";
|
||||||
}
|
}
|
||||||
|
|
||||||
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostEnvironment>();
|
||||||
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
||||||
}))
|
}))
|
||||||
.Build()
|
.Build()
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace StartRequestDelegateUrlApp
|
namespace StartRequestDelegateUrlApp
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +20,7 @@ namespace StartRequestDelegateUrlApp
|
||||||
using (var host = WebHost.Start("http://127.0.0.1:0", async context =>
|
using (var host = WebHost.Start("http://127.0.0.1:0", async context =>
|
||||||
{
|
{
|
||||||
// Respond with the ApplicationName.
|
// Respond with the ApplicationName.
|
||||||
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
var env = context.RequestServices.GetRequiredService<IHostEnvironment>();
|
||||||
await context.Response.WriteAsync(env.ApplicationName);
|
await context.Response.WriteAsync(env.ApplicationName);
|
||||||
messageSent.Set();
|
messageSent.Set();
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace StartRequestDelegateUrlApp
|
namespace StartRequestDelegateUrlApp
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +21,7 @@ namespace StartRequestDelegateUrlApp
|
||||||
using (var host = WebHost.Start("http://127.0.0.1:0", router =>
|
using (var host = WebHost.Start("http://127.0.0.1:0", router =>
|
||||||
router.MapGet("route", async (req, res, data) =>
|
router.MapGet("route", async (req, res, data) =>
|
||||||
{
|
{
|
||||||
var env = req.HttpContext.RequestServices.GetRequiredService<IHostingEnvironment>();
|
var env = req.HttpContext.RequestServices.GetRequiredService<IHostEnvironment>();
|
||||||
await res.WriteAsync(env.ApplicationName);
|
await res.WriteAsync(env.ApplicationName);
|
||||||
messageSent.Set();
|
messageSent.Set();
|
||||||
})))
|
})))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace StartWithIApplicationBuilderUrlApp
|
namespace StartWithIApplicationBuilderUrlApp
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,7 @@ namespace StartWithIApplicationBuilderUrlApp
|
||||||
{
|
{
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
{
|
{
|
||||||
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
var env = context.RequestServices.GetRequiredService<IHostEnvironment>();
|
||||||
await context.Response.WriteAsync(env.ApplicationName);
|
await context.Response.WriteAsync(env.ApplicationName);
|
||||||
messageSent.Set();
|
messageSent.Set();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
namespace Microsoft.AspNetCore.Hosting
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -78,3 +78,4 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows consumers to perform cleanup during a graceful shutdown.
|
/// Allows consumers to perform cleanup during a graceful shutdown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[System.Obsolete("Use Microsoft.Extensions.Hosting.IHostApplicationLifetime instead.", error: false)]
|
||||||
public interface IApplicationLifetime
|
public interface IApplicationLifetime
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides information about the web hosting environment an application is running in.
|
/// Provides information about the web hosting environment an application is running in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[System.Obsolete("Use IWebHostEnvironment instead.", error: false)]
|
||||||
public interface IHostingEnvironment
|
public interface IHostingEnvironment
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides information about the web hosting environment an application is running in.
|
||||||
|
/// </summary>
|
||||||
|
public interface IWebHostEnvironment : IHostEnvironment
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the absolute path to the directory that contains the web-servable application content files.
|
||||||
|
/// </summary>
|
||||||
|
string WebRootPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets an <see cref="IFileProvider"/> pointing at <see cref="WebRootPath"/>.
|
||||||
|
/// </summary>
|
||||||
|
IFileProvider WebRootFileProvider { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
public class WebHostBuilderContext
|
public class WebHostBuilderContext
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="IHostingEnvironment" /> initialized by the <see cref="IWebHost" />.
|
/// The <see cref="IWebHostEnvironment" /> initialized by the <see cref="IWebHost" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IHostingEnvironment HostingEnvironment { get; set; }
|
public IWebHostEnvironment HostingEnvironment { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="IConfiguration" /> containing the merged configuration of the application and the <see cref="IWebHost" />.
|
/// The <see cref="IConfiguration" /> containing the merged configuration of the application and the <see cref="IWebHost" />.
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,16 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
{
|
{
|
||||||
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
|
|
||||||
{
|
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime;
|
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
|
||||||
public GenericWebHostApplicationLifetime(Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime)
|
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
{
|
||||||
|
private readonly IHostApplicationLifetime _applicationLifetime;
|
||||||
|
public GenericWebHostApplicationLifetime(IHostApplicationLifetime applicationLifetime)
|
||||||
{
|
{
|
||||||
_applicationLifetime = applicationLifetime;
|
_applicationLifetime = applicationLifetime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,10 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
|
|
||||||
// Add the IHostingEnvironment and IApplicationLifetime from Microsoft.AspNetCore.Hosting
|
// Add the IHostingEnvironment and IApplicationLifetime from Microsoft.AspNetCore.Hosting
|
||||||
services.AddSingleton(webhostContext.HostingEnvironment);
|
services.AddSingleton(webhostContext.HostingEnvironment);
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
services.AddSingleton((AspNetCore.Hosting.IHostingEnvironment)webhostContext.HostingEnvironment);
|
||||||
services.AddSingleton<IApplicationLifetime, GenericWebHostApplicationLifetime>();
|
services.AddSingleton<IApplicationLifetime, GenericWebHostApplicationLifetime>();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
services.Configure<GenericWebHostServiceOptions>(options =>
|
services.Configure<GenericWebHostServiceOptions>(options =>
|
||||||
{
|
{
|
||||||
|
|
@ -318,14 +321,12 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
if (!context.Properties.TryGetValue(typeof(WebHostBuilderContext), out var contextVal))
|
if (!context.Properties.TryGetValue(typeof(WebHostBuilderContext), out var contextVal))
|
||||||
{
|
{
|
||||||
var options = new WebHostOptions(context.Configuration, Assembly.GetEntryAssembly()?.GetName().Name);
|
var options = new WebHostOptions(context.Configuration, Assembly.GetEntryAssembly()?.GetName().Name);
|
||||||
var hostingEnvironment = new HostingEnvironment();
|
|
||||||
hostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options);
|
|
||||||
|
|
||||||
var webHostBuilderContext = new WebHostBuilderContext
|
var webHostBuilderContext = new WebHostBuilderContext
|
||||||
{
|
{
|
||||||
Configuration = context.Configuration,
|
Configuration = context.Configuration,
|
||||||
HostingEnvironment = hostingEnvironment
|
HostingEnvironment = new HostingEnvironment(),
|
||||||
};
|
};
|
||||||
|
webHostBuilderContext.HostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options);
|
||||||
context.Properties[typeof(WebHostBuilderContext)] = webHostBuilderContext;
|
context.Properties[typeof(WebHostBuilderContext)] = webHostBuilderContext;
|
||||||
context.Properties[typeof(WebHostOptions)] = options;
|
context.Properties[typeof(WebHostOptions)] = options;
|
||||||
return webHostBuilderContext;
|
return webHostBuilderContext;
|
||||||
|
|
@ -361,7 +362,13 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
public object GetService(Type serviceType)
|
public object GetService(Type serviceType)
|
||||||
{
|
{
|
||||||
// The implementation of the HostingEnvironment supports both interfaces
|
// The implementation of the HostingEnvironment supports both interfaces
|
||||||
if (serviceType == typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment) || serviceType == typeof(IHostingEnvironment))
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
if (serviceType == typeof(Microsoft.Extensions.Hosting.IHostingEnvironment)
|
||||||
|
|| serviceType == typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|| serviceType == typeof(IWebHostEnvironment)
|
||||||
|
|| serviceType == typeof(IHostEnvironment)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return _context.HostingEnvironment;
|
return _context.HostingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
IApplicationBuilderFactory applicationBuilderFactory,
|
IApplicationBuilderFactory applicationBuilderFactory,
|
||||||
IEnumerable<IStartupFilter> startupFilters,
|
IEnumerable<IStartupFilter> startupFilters,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
IHostingEnvironment hostingEnvironment)
|
IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
Options = options.Value;
|
Options = options.Value;
|
||||||
Server = server;
|
Server = server;
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
public IApplicationBuilderFactory ApplicationBuilderFactory { get; }
|
public IApplicationBuilderFactory ApplicationBuilderFactory { get; }
|
||||||
public IEnumerable<IStartupFilter> StartupFilters { get; }
|
public IEnumerable<IStartupFilter> StartupFilters { get; }
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
public IHostingEnvironment HostingEnvironment { get; }
|
public IWebHostEnvironment HostingEnvironment { get; }
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
|
|
@ -11,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
/// Allows consumers to perform cleanup during a graceful shutdown.
|
/// Allows consumers to perform cleanup during a graceful shutdown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime
|
public class ApplicationLifetime : IApplicationLifetime, Extensions.Hosting.IApplicationLifetime, IHostApplicationLifetime
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
private readonly CancellationTokenSource _startedSource = new CancellationTokenSource();
|
private readonly CancellationTokenSource _startedSource = new CancellationTokenSource();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.FileProviders;
|
||||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment
|
public class HostingEnvironment : IHostingEnvironment, Extensions.Hosting.IHostingEnvironment, IWebHostEnvironment
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
|
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,62 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
{
|
{
|
||||||
public static class HostingEnvironmentExtensions
|
public static class HostingEnvironmentExtensions
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public static void Initialize(this IHostingEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options)
|
public static void Initialize(this IHostingEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options)
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
{
|
||||||
|
if (options == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(options));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(contentRootPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("A valid non-empty content root must be provided.", nameof(contentRootPath));
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(contentRootPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"The content root '{contentRootPath}' does not exist.", nameof(contentRootPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
hostingEnvironment.ApplicationName = options.ApplicationName;
|
||||||
|
hostingEnvironment.ContentRootPath = contentRootPath;
|
||||||
|
hostingEnvironment.ContentRootFileProvider = new PhysicalFileProvider(hostingEnvironment.ContentRootPath);
|
||||||
|
|
||||||
|
var webRoot = options.WebRoot;
|
||||||
|
if (webRoot == null)
|
||||||
|
{
|
||||||
|
// Default to /wwwroot if it exists.
|
||||||
|
var wwwroot = Path.Combine(hostingEnvironment.ContentRootPath, "wwwroot");
|
||||||
|
if (Directory.Exists(wwwroot))
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = wwwroot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = Path.Combine(hostingEnvironment.ContentRootPath, webRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(hostingEnvironment.WebRootPath))
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootPath = Path.GetFullPath(hostingEnvironment.WebRootPath);
|
||||||
|
if (!Directory.Exists(hostingEnvironment.WebRootPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(hostingEnvironment.WebRootPath);
|
||||||
|
}
|
||||||
|
hostingEnvironment.WebRootFileProvider = new PhysicalFileProvider(hostingEnvironment.WebRootPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hostingEnvironment.WebRootFileProvider = new NullFileProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
hostingEnvironment.EnvironmentName =
|
||||||
|
options.Environment ??
|
||||||
|
hostingEnvironment.EnvironmentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Initialize(this IWebHostEnvironment hostingEnvironment, string contentRootPath, WebHostOptions options)
|
||||||
{
|
{
|
||||||
if (options == null)
|
if (options == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.StackTrace.Sources;
|
using Microsoft.Extensions.StackTrace.Sources;
|
||||||
|
|
||||||
|
|
@ -76,14 +77,16 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
_options = options;
|
_options = options;
|
||||||
_applicationServiceCollection = appServices;
|
_applicationServiceCollection = appServices;
|
||||||
_hostingServiceProvider = hostingServiceProvider;
|
_hostingServiceProvider = hostingServiceProvider;
|
||||||
_applicationServiceCollection.AddSingleton<IApplicationLifetime, ApplicationLifetime>();
|
_applicationServiceCollection.AddSingleton<ApplicationLifetime>();
|
||||||
// There's no way to to register multiple service types per definition. See https://github.com/aspnet/DependencyInjection/issues/360
|
// There's no way to to register multiple service types per definition. See https://github.com/aspnet/DependencyInjection/issues/360
|
||||||
_applicationServiceCollection.AddSingleton(sp =>
|
_applicationServiceCollection.AddSingleton(services
|
||||||
{
|
=> services.GetService<ApplicationLifetime>() as IHostApplicationLifetime);
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
return sp.GetRequiredService<IApplicationLifetime>() as Extensions.Hosting.IApplicationLifetime;
|
_applicationServiceCollection.AddSingleton(services
|
||||||
|
=> services.GetService<ApplicationLifetime>() as AspNetCore.Hosting.IApplicationLifetime);
|
||||||
|
_applicationServiceCollection.AddSingleton(services
|
||||||
|
=> services.GetService<ApplicationLifetime>() as Extensions.Hosting.IApplicationLifetime);
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
});
|
|
||||||
_applicationServiceCollection.AddSingleton<HostedServiceExecutor>();
|
_applicationServiceCollection.AddSingleton<HostedServiceExecutor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +144,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
|
|
||||||
var application = BuildApplication();
|
var application = BuildApplication();
|
||||||
|
|
||||||
_applicationLifetime = _applicationServices.GetRequiredService<IApplicationLifetime>() as ApplicationLifetime;
|
_applicationLifetime = _applicationServices.GetRequiredService<ApplicationLifetime>();
|
||||||
_hostedServiceExecutor = _applicationServices.GetRequiredService<HostedServiceExecutor>();
|
_hostedServiceExecutor = _applicationServices.GetRequiredService<HostedServiceExecutor>();
|
||||||
var diagnosticSource = _applicationServices.GetRequiredService<DiagnosticListener>();
|
var diagnosticSource = _applicationServices.GetRequiredService<DiagnosticListener>();
|
||||||
var httpContextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
var httpContextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
||||||
|
|
@ -238,7 +241,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
||||||
EnsureServer();
|
EnsureServer();
|
||||||
|
|
||||||
// Generate an HTML error page.
|
// Generate an HTML error page.
|
||||||
var hostingEnv = _applicationServices.GetRequiredService<IHostingEnvironment>();
|
var hostingEnv = _applicationServices.GetRequiredService<IHostEnvironment>();
|
||||||
var showDetailedErrors = hostingEnv.IsDevelopment() || _options.DetailedErrors;
|
var showDetailedErrors = hostingEnv.IsDevelopment() || _options.DetailedErrors;
|
||||||
|
|
||||||
var model = new ErrorPageModel
|
var model = new ErrorPageModel
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.ObjectPool;
|
using Microsoft.Extensions.ObjectPool;
|
||||||
|
|
||||||
|
|
@ -248,13 +249,15 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, AppContext.BaseDirectory);
|
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, AppContext.BaseDirectory);
|
||||||
|
|
||||||
// Initialize the hosting environment
|
// Initialize the hosting environment
|
||||||
_hostingEnvironment.Initialize(contentRootPath, _options);
|
((IWebHostEnvironment)_hostingEnvironment).Initialize(contentRootPath, _options);
|
||||||
_context.HostingEnvironment = _hostingEnvironment;
|
_context.HostingEnvironment = _hostingEnvironment;
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddSingleton(_options);
|
services.AddSingleton(_options);
|
||||||
services.AddSingleton<IHostingEnvironment>(_hostingEnvironment);
|
services.AddSingleton<IWebHostEnvironment>(_hostingEnvironment);
|
||||||
|
services.AddSingleton<IHostEnvironment>(_hostingEnvironment);
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
services.AddSingleton<AspNetCore.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
||||||
services.AddSingleton<Extensions.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
services.AddSingleton<Extensions.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
services.AddSingleton(_context);
|
services.AddSingleton(_context);
|
||||||
|
|
@ -295,7 +298,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
services.AddSingleton(typeof(IStartup), sp =>
|
services.AddSingleton(typeof(IStartup), sp =>
|
||||||
{
|
{
|
||||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
var hostingEnvironment = sp.GetRequiredService<IHostEnvironment>();
|
||||||
var methods = StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName);
|
var methods = StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName);
|
||||||
return new ConventionBasedStartup(methods);
|
return new ConventionBasedStartup(methods);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting.Internal;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
@ -76,7 +77,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
services.AddSingleton(typeof(IStartup), sp =>
|
services.AddSingleton(typeof(IStartup), sp =>
|
||||||
{
|
{
|
||||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
var hostingEnvironment = sp.GetRequiredService<IHostEnvironment>();
|
||||||
return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName));
|
return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.AspNetCore.Hosting.Internal;
|
using Microsoft.AspNetCore.Hosting.Internal;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
|
|
@ -105,7 +106,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
await host.StartAsync(token);
|
await host.StartAsync(token);
|
||||||
|
|
||||||
var hostingEnvironment = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnvironment = host.Services.GetService<IHostEnvironment>();
|
||||||
var options = host.Services.GetRequiredService<WebHostOptions>();
|
var options = host.Services.GetRequiredService<WebHostOptions>();
|
||||||
|
|
||||||
if (!options.SuppressStatusMessages)
|
if (!options.SuppressStatusMessages)
|
||||||
|
|
@ -146,11 +147,11 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
private static async Task WaitForTokenShutdownAsync(this IWebHost host, CancellationToken token)
|
private static async Task WaitForTokenShutdownAsync(this IWebHost host, CancellationToken token)
|
||||||
{
|
{
|
||||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
token.Register(state =>
|
token.Register(state =>
|
||||||
{
|
{
|
||||||
((IApplicationLifetime)state).StopApplication();
|
((IHostApplicationLifetime)state).StopApplication();
|
||||||
},
|
},
|
||||||
applicationLifetime);
|
applicationLifetime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
using System;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.Tests.Fakes
|
namespace Microsoft.AspNetCore.Hosting.Tests.Fakes
|
||||||
{
|
{
|
||||||
public class StartupWithHostingEnvironment
|
public class StartupWithHostingEnvironment
|
||||||
{
|
{
|
||||||
public StartupWithHostingEnvironment(IHostingEnvironment env)
|
public StartupWithHostingEnvironment(IHostEnvironment env)
|
||||||
{
|
{
|
||||||
env.EnvironmentName = "Changed";
|
env.EnvironmentName = "Changed";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SetsFullPathToWwwroot()
|
public void SetsFullPathToWwwroot()
|
||||||
{
|
{
|
||||||
var env = new HostingEnvironment();
|
IWebHostEnvironment env = new HostingEnvironment();
|
||||||
|
|
||||||
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { WebRoot = "testroot" });
|
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { WebRoot = "testroot" });
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void DefaultsToWwwrootSubdir()
|
public void DefaultsToWwwrootSubdir()
|
||||||
{
|
{
|
||||||
var env = new HostingEnvironment();
|
IWebHostEnvironment env = new HostingEnvironment();
|
||||||
|
|
||||||
env.Initialize(Path.GetFullPath("testroot"), new WebHostOptions());
|
env.Initialize(Path.GetFullPath("testroot"), new WebHostOptions());
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void DefaultsToNullFileProvider()
|
public void DefaultsToNullFileProvider()
|
||||||
{
|
{
|
||||||
var env = new HostingEnvironment();
|
IWebHostEnvironment env = new HostingEnvironment();
|
||||||
|
|
||||||
env.Initialize(Path.GetFullPath(Path.Combine("testroot", "wwwroot")), new WebHostOptions());
|
env.Initialize(Path.GetFullPath(Path.Combine("testroot", "wwwroot")), new WebHostOptions());
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void OverridesEnvironmentFromConfig()
|
public void OverridesEnvironmentFromConfig()
|
||||||
{
|
{
|
||||||
var env = new HostingEnvironment();
|
IWebHostEnvironment env = new HostingEnvironment();
|
||||||
env.EnvironmentName = "SomeName";
|
env.EnvironmentName = "SomeName";
|
||||||
|
|
||||||
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { Environment = "NewName" });
|
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { Environment = "NewName" });
|
||||||
|
|
|
||||||
|
|
@ -98,14 +98,14 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(DefaultWebHostBuildersWithConfig))]
|
[MemberData(nameof(DefaultWebHostBuildersWithConfig))]
|
||||||
public async Task IApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder)
|
public async Task IHostApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder)
|
||||||
{
|
{
|
||||||
var server = new TestServer();
|
var server = new TestServer();
|
||||||
var host = builder.UseServer(server).UseStartup<StartupCtorThrows>().Build();
|
var host = builder.UseServer(server).UseStartup<StartupCtorThrows>().Build();
|
||||||
using (host)
|
using (host)
|
||||||
{
|
{
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
var services = host.Services.GetServices<IApplicationLifetime>();
|
var services = host.Services.GetServices<IHostApplicationLifetime>();
|
||||||
Assert.NotNull(services);
|
Assert.NotNull(services);
|
||||||
Assert.NotEmpty(services);
|
Assert.NotEmpty(services);
|
||||||
|
|
||||||
|
|
@ -551,8 +551,10 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
Assert.Equal(expected, host.Services.GetService<IHostingEnvironment>().EnvironmentName);
|
Assert.Equal(expected, host.Services.GetService<IHostEnvironment>().EnvironmentName);
|
||||||
|
Assert.Equal(expected, host.Services.GetService<IWebHostEnvironment>().EnvironmentName);
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
Assert.Equal(expected, host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().EnvironmentName);
|
||||||
Assert.Equal(expected, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().EnvironmentName);
|
Assert.Equal(expected, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().EnvironmentName);
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
@ -598,8 +600,10 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
Assert.Equal("/", host.Services.GetService<IHostingEnvironment>().ContentRootPath);
|
Assert.Equal("/", host.Services.GetService<IHostEnvironment>().ContentRootPath);
|
||||||
|
Assert.Equal("/", host.Services.GetService<IWebHostEnvironment>().ContentRootPath);
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
Assert.Equal("/", host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||||
Assert.Equal("/", host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
Assert.Equal("/", host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
|
|
@ -615,9 +619,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var basePath = host.Services.GetRequiredService<IHostingEnvironment>().ContentRootPath;
|
var basePath = host.Services.GetRequiredService<IHostEnvironment>().ContentRootPath;
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var basePath2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath;
|
var basePath2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath;
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
Assert.True(Path.IsPathRooted(basePath));
|
Assert.True(Path.IsPathRooted(basePath));
|
||||||
|
|
@ -638,9 +642,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var appBase = AppContext.BaseDirectory;
|
var appBase = AppContext.BaseDirectory;
|
||||||
Assert.Equal(appBase, host.Services.GetService<IHostingEnvironment>().ContentRootPath);
|
Assert.Equal(appBase, host.Services.GetService<IHostEnvironment>().ContentRootPath);
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(appBase, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
Assert.Equal(appBase, host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -666,9 +670,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup(typeof(Startup).Assembly.GetName().Name)
|
.UseStartup(typeof(Startup).Assembly.GetName().Name)
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var hostingEnv2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
var hostingEnv2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||||
|
|
@ -684,9 +688,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup<StartupNoServicesNoInterface>()
|
.UseStartup<StartupNoServicesNoInterface>()
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var hostingEnv2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
var hostingEnv2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||||
|
|
@ -702,7 +706,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup(typeof(StartupNoServicesNoInterface))
|
.UseStartup(typeof(StartupNoServicesNoInterface))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -715,7 +719,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.Configure(app => { })
|
.Configure(app => { })
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
|
|
||||||
// Should be the assembly containing this test, because that's where the delegate comes from
|
// Should be the assembly containing this test, because that's where the delegate comes from
|
||||||
Assert.Equal(typeof(WebHostBuilderTests).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
Assert.Equal(typeof(WebHostBuilderTests).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||||
|
|
@ -731,7 +735,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.Configure(app => { })
|
.Configure(app => { })
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -745,7 +749,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.Configure(StaticConfigureMethod)
|
.Configure(StaticConfigureMethod)
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||||
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var lifetime2 = host.Services.GetRequiredService<Extensions.Hosting.IApplicationLifetime>();
|
var lifetime2 = host.Services.GetRequiredService<AspNetCore.Hosting.IApplicationLifetime>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
var server = (FakeServer)host.Services.GetRequiredService<IServer>();
|
var server = (FakeServer)host.Services.GetRequiredService<IServer>();
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
var applicationStartedEvent = new ManualResetEventSlim(false);
|
var applicationStartedEvent = new ManualResetEventSlim(false);
|
||||||
var applicationStoppingEvent = new ManualResetEventSlim(false);
|
var applicationStoppingEvent = new ManualResetEventSlim(false);
|
||||||
var applicationStoppedEvent = new ManualResetEventSlim(false);
|
var applicationStoppedEvent = new ManualResetEventSlim(false);
|
||||||
|
|
@ -416,9 +416,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseFakeServer()
|
.UseFakeServer()
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
Assert.False(applicationLifetime.ApplicationStarted.IsCancellationRequested);
|
Assert.False(applicationLifetime.ApplicationStarted.IsCancellationRequested);
|
||||||
|
|
@ -437,9 +437,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.UseFakeServer()
|
.UseFakeServer()
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||||
|
|
@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
lifetime.StopApplication();
|
lifetime.StopApplication();
|
||||||
|
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
|
|
@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
lifetime.StopApplication();
|
lifetime.StopApplication();
|
||||||
|
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
|
|
@ -562,7 +562,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
lifetime.StopApplication();
|
lifetime.StopApplication();
|
||||||
|
|
||||||
var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>();
|
var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>();
|
||||||
|
|
@ -605,7 +605,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
Assert.Equal(0, startedCalls);
|
Assert.Equal(0, startedCalls);
|
||||||
|
|
||||||
|
|
@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
Assert.Equal(0, startedCalls);
|
Assert.Equal(0, startedCalls);
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
|
|
@ -687,9 +687,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
})
|
})
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var applicationLifetime2 = host.Services.GetService<Extensions.Hosting.IApplicationLifetime>();
|
var applicationLifetime2 = host.Services.GetService<AspNetCore.Hosting.IApplicationLifetime>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
|
||||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||||
|
|
@ -721,9 +721,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
.Build())
|
.Build())
|
||||||
{
|
{
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
var env = host.Services.GetService<IHostingEnvironment>();
|
var env = host.Services.GetService<IHostEnvironment>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal("Changed", env.EnvironmentName);
|
Assert.Equal("Changed", env.EnvironmentName);
|
||||||
Assert.Equal("Changed", env2.EnvironmentName);
|
Assert.Equal("Changed", env2.EnvironmentName);
|
||||||
|
|
@ -808,9 +808,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
using (var host = CreateBuilder().UseFakeServer().Build())
|
using (var host = CreateBuilder().UseFakeServer().Build())
|
||||||
{
|
{
|
||||||
var env = host.Services.GetService<IHostingEnvironment>();
|
var env = host.Services.GetService<IHostEnvironment>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
|
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
|
||||||
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
|
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
|
||||||
|
|
@ -831,9 +831,9 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
using (var host = CreateBuilder(config).UseFakeServer().Build())
|
using (var host = CreateBuilder(config).UseFakeServer().Build())
|
||||||
{
|
{
|
||||||
var env = host.Services.GetService<IHostingEnvironment>();
|
var env = host.Services.GetService<IHostEnvironment>();
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
var env2 = host.Services.GetService<Extensions.Hosting.IHostingEnvironment>();
|
var env2 = host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>();
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
||||||
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
Assert.Equal(EnvironmentName.Staging, env.EnvironmentName);
|
||||||
|
|
@ -854,9 +854,15 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
using (var host = CreateBuilder(config).UseFakeServer().Build())
|
using (var host = CreateBuilder(config).UseFakeServer().Build())
|
||||||
{
|
{
|
||||||
var env = host.Services.GetService<IHostingEnvironment>();
|
var env = host.Services.GetService<IWebHostEnvironment>();
|
||||||
Assert.Equal(Path.GetFullPath("testroot"), env.WebRootPath);
|
Assert.Equal(Path.GetFullPath("testroot"), env.WebRootPath);
|
||||||
Assert.True(env.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists);
|
Assert.True(env.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists);
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
var env1 = host.Services.GetService<IHostingEnvironment>();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
Assert.Equal(Path.GetFullPath("testroot"), env1.WebRootPath);
|
||||||
|
Assert.True(env1.WebRootFileProvider.GetFileInfo("TextFile.txt").Exists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -866,7 +872,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
using (var host = CreateBuilder().UseFakeServer().Build())
|
using (var host = CreateBuilder().UseFakeServer().Build())
|
||||||
{
|
{
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
var env = host.Services.GetRequiredService<IHostingEnvironment>();
|
var env = host.Services.GetRequiredService<IHostEnvironment>();
|
||||||
Assert.True(env.IsEnvironment(EnvironmentName.Production));
|
Assert.True(env.IsEnvironment(EnvironmentName.Production));
|
||||||
Assert.True(env.IsEnvironment("producTion"));
|
Assert.True(env.IsEnvironment("producTion"));
|
||||||
}
|
}
|
||||||
|
|
@ -1034,10 +1040,12 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
private class TestHostedService : IHostedService, IDisposable
|
private class TestHostedService : IHostedService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IApplicationLifetime _lifetime;
|
private readonly IHostApplicationLifetime _lifetime;
|
||||||
|
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
public TestHostedService(IApplicationLifetime lifetime, Extensions.Hosting.IApplicationLifetime lifetime2)
|
public TestHostedService(IHostApplicationLifetime lifetime,
|
||||||
|
AspNetCore.Hosting.IApplicationLifetime lifetime1,
|
||||||
|
Extensions.Hosting.IApplicationLifetime lifetime2)
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
{
|
{
|
||||||
_lifetime = lifetime;
|
_lifetime = lifetime;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.WindowsServices
|
namespace Microsoft.AspNetCore.Hosting.WindowsServices
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +45,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices
|
||||||
// race conditions.
|
// race conditions.
|
||||||
_host
|
_host
|
||||||
.Services
|
.Services
|
||||||
.GetRequiredService<IApplicationLifetime>()
|
.GetRequiredService<IHostApplicationLifetime>()
|
||||||
.ApplicationStopping
|
.ApplicationStopping
|
||||||
.Register(() =>
|
.Register(() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder().UseServer(new FakeServer()).Configure(x => { }).Build();
|
var host = new WebHostBuilder().UseServer(new FakeServer()).Configure(x => { }).Build();
|
||||||
var webHostService = new WebHostService(host);
|
var webHostService = new WebHostService(host);
|
||||||
var applicationLifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
applicationLifetime.StopApplication();
|
applicationLifetime.StopApplication();
|
||||||
webHostService.Start();
|
webHostService.Start();
|
||||||
|
|
@ -39,7 +40,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder().UseServer( new FakeServer() ).Configure( x => { } ).Build();
|
var host = new WebHostBuilder().UseServer( new FakeServer() ).Configure( x => { } ).Build();
|
||||||
var webHostService = new WebHostService(host);
|
var webHostService = new WebHostService(host);
|
||||||
var applicationLifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
webHostService.Start();
|
webHostService.Start();
|
||||||
applicationLifetime.StopApplication();
|
applicationLifetime.StopApplication();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace IStartupInjectionAssemblyName
|
namespace IStartupInjectionAssemblyName
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +13,7 @@ namespace IStartupInjectionAssemblyName
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var webHost = CreateWebHostBuilder(args).Build();
|
var webHost = CreateWebHostBuilder(args).Build();
|
||||||
var applicationName = webHost.Services.GetRequiredService<IHostingEnvironment>().ApplicationName;
|
var applicationName = webHost.Services.GetRequiredService<IHostEnvironment>().ApplicationName;
|
||||||
Console.WriteLine(applicationName);
|
Console.WriteLine(applicationName);
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,14 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting.TestSites
|
namespace Microsoft.AspNetCore.Hosting.TestSites
|
||||||
{
|
{
|
||||||
public class StartupShutdown
|
public class StartupShutdown
|
||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationLifetime lifetime)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostApplicationLifetime lifetime)
|
||||||
{
|
{
|
||||||
lifetime.ApplicationStarted.Register(() =>
|
lifetime.ApplicationStarted.Register(() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using ApiAuthSample.Data;
|
using ApiAuthSample.Data;
|
||||||
using ApiAuthSample.Models;
|
using ApiAuthSample.Models;
|
||||||
|
|
||||||
|
|
@ -42,7 +43,7 @@ namespace ApiAuthSample
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme;
|
var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme;
|
||||||
|
|
||||||
var localApiDescriptor = sp.GetRequiredService<IIdentityServerJwtDescriptor>();
|
var localApiDescriptor = sp.GetRequiredService<IIdentityServerJwtDescriptor>();
|
||||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
var hostingEnvironment = sp.GetRequiredService<IWebHostEnvironment>();
|
||||||
var apiName = hostingEnvironment.ApplicationName + IdentityServerJwtNameSuffix;
|
var apiName = hostingEnvironment.ApplicationName + IdentityServerJwtNameSuffix;
|
||||||
|
|
||||||
return new IdentityServerJwtBearerOptionsConfiguration(schemeName, apiName, localApiDescriptor);
|
return new IdentityServerJwtBearerOptionsConfiguration(schemeName, apiName, localApiDescriptor);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -8,12 +8,12 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
|
||||||
{
|
{
|
||||||
internal class IdentityServerJwtDescriptor : IIdentityServerJwtDescriptor
|
internal class IdentityServerJwtDescriptor : IIdentityServerJwtDescriptor
|
||||||
{
|
{
|
||||||
public IdentityServerJwtDescriptor(IHostingEnvironment environment)
|
public IdentityServerJwtDescriptor(IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
Environment = environment;
|
Environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostingEnvironment Environment { get; }
|
public IWebHostEnvironment Environment { get; }
|
||||||
|
|
||||||
public IDictionary<string, ResourceDefinition> GetResourceDefinitions()
|
public IDictionary<string, ResourceDefinition> GetResourceDefinitions()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
|
||||||
public void LocalApiDescriptor_DefinesApiResources()
|
public void LocalApiDescriptor_DefinesApiResources()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var environment = new Mock<IHostingEnvironment>();
|
var environment = new Mock<IWebHostEnvironment>();
|
||||||
environment.SetupGet(e => e.ApplicationName).Returns("Test");
|
environment.SetupGet(e => e.ApplicationName).Returns("Test");
|
||||||
var descriptor = new IdentityServerJwtDescriptor(environment.Object);
|
var descriptor = new IdentityServerJwtDescriptor(environment.Object);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@using Microsoft.AspNetCore.Hosting
|
@using Microsoft.AspNetCore.Hosting
|
||||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||||
@inject IHostingEnvironment Environment
|
@inject IWebHostEnvironment Environment
|
||||||
@inject ICompositeViewEngine Engine
|
@inject ICompositeViewEngine Engine
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@using Microsoft.AspNetCore.Hosting
|
@using Microsoft.AspNetCore.Hosting
|
||||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||||
@inject IHostingEnvironment Environment
|
@inject IWebHostEnvironment Environment
|
||||||
@inject ICompositeViewEngine Engine
|
@inject ICompositeViewEngine Engine
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@ namespace Microsoft.AspNetCore.Identity.UI
|
||||||
private const string IdentityUIDefaultAreaName = "Identity";
|
private const string IdentityUIDefaultAreaName = "Identity";
|
||||||
|
|
||||||
public IdentityDefaultUIConfigureOptions(
|
public IdentityDefaultUIConfigureOptions(
|
||||||
IHostingEnvironment environment,
|
IWebHostEnvironment environment,
|
||||||
IOptions<DefaultUIOptions> uiOptions)
|
IOptions<DefaultUIOptions> uiOptions)
|
||||||
{
|
{
|
||||||
Environment = environment;
|
Environment = environment;
|
||||||
UiOptions = uiOptions;
|
UiOptions = uiOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostingEnvironment Environment { get; }
|
public IWebHostEnvironment Environment { get; }
|
||||||
public IOptions<DefaultUIOptions> UiOptions { get; }
|
public IOptions<DefaultUIOptions> UiOptions { get; }
|
||||||
|
|
||||||
public void PostConfigure(string name, RazorPagesOptions options)
|
public void PostConfigure(string name, RazorPagesOptions options)
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IdentitySample.DefaultUI
|
namespace IdentitySample.DefaultUI
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IHostingEnvironment env)
|
public Startup(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(env.ContentRootPath)
|
.SetBasePath(env.ContentRootPath)
|
||||||
|
|
@ -43,7 +44,7 @@ namespace IdentitySample.DefaultUI
|
||||||
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IdentitySample
|
namespace IdentitySample
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IHostingEnvironment env)
|
public Startup(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(env.ContentRootPath)
|
.SetBasePath(env.ContentRootPath)
|
||||||
|
|
@ -55,7 +56,7 @@ namespace IdentitySample
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Identity.DefaultUI.WebSite
|
namespace Identity.DefaultUI.WebSite
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +40,7 @@ namespace Identity.DefaultUI.WebSite
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Identity.DefaultUI.WebSite
|
namespace Identity.DefaultUI.WebSite
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Identity.DefaultUI.WebSite
|
namespace Identity.DefaultUI.WebSite
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +54,7 @@ namespace Identity.DefaultUI.WebSite
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace SampleDestination
|
||||||
services.AddRouting();
|
services.AddRouting();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseRouting(routing =>
|
app.UseRouting(routing =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace SampleDestination
|
||||||
services.AddCors();
|
services.AddCors();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Map("/allow-origin", innerBuilder =>
|
app.Map("/allow-origin", innerBuilder =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -15,7 +15,7 @@ namespace SampleOrigin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseDefaultFiles();
|
app.UseDefaultFiles();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
||||||
RequestDelegate next,
|
RequestDelegate next,
|
||||||
IOptions<DeveloperExceptionPageOptions> options,
|
IOptions<DeveloperExceptionPageOptions> options,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IHostingEnvironment hostingEnvironment,
|
IWebHostEnvironment hostingEnvironment,
|
||||||
DiagnosticSource diagnosticSource)
|
DiagnosticSource diagnosticSource)
|
||||||
{
|
{
|
||||||
if (next == null)
|
if (next == null)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace HealthChecksSample
|
||||||
services.AddHealthChecks();
|
services.AddHealthChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware at the URL /health.
|
// This will register the health checks middleware at the URL /health.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
|
|
@ -23,7 +23,7 @@ namespace HealthChecksSample
|
||||||
.AddGCInfoCheck("GCInfo");
|
.AddGCInfoCheck("GCInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware at the URL /health
|
// This will register the health checks middleware at the URL /health
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
@ -25,7 +25,7 @@ namespace HealthChecksSample
|
||||||
.AddCheck("MyDatabase", new SqlConnectionHealthCheck(Configuration["ConnectionStrings:DefaultConnection"]));
|
.AddCheck("MyDatabase", new SqlConnectionHealthCheck(Configuration["ConnectionStrings:DefaultConnection"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware at the URL /health.
|
// This will register the health checks middleware at the URL /health.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace HealthChecksSample
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware at the URL /health.
|
// This will register the health checks middleware at the URL /health.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -18,7 +18,7 @@ namespace HealthChecksSample
|
||||||
.AddCheck<SlowDependencyHealthCheck>("Slow", failureStatus: null, tags: new[] { "ready", });
|
.AddCheck<SlowDependencyHealthCheck>("Slow", failureStatus: null, tags: new[] { "ready", });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware twice:
|
// This will register the health checks middleware twice:
|
||||||
// - at /health/ready for 'readiness'
|
// - at /health/ready for 'readiness'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
@ -22,7 +22,7 @@ namespace HealthChecksSample
|
||||||
services.AddHealthChecks();
|
services.AddHealthChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// This will register the health checks middleware at the URL /health but only on the specified port.
|
// This will register the health checks middleware at the URL /health but only on the specified port.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -44,7 +44,7 @@ namespace HostFilteringSample
|
||||||
services.AddSingleton<IOptionsChangeTokenSource<HostFilteringOptions>>(new ConfigurationChangeTokenSource<HostFilteringOptions>(Config));
|
services.AddSingleton<IOptionsChangeTokenSource<HostFilteringOptions>>(new ConfigurationChangeTokenSource<HostFilteringOptions>(Config));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseHostFiltering();
|
app.UseHostFiltering();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
using Microsoft.AspNetCore.HttpsPolicy;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace HttpsSample
|
namespace HttpsSample
|
||||||
|
|
@ -33,7 +34,7 @@ namespace HttpsSample
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment environment)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
if (!environment.IsDevelopment())
|
if (!environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleOrigin", "CORS\sample
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NodeServices", "NodeServices", "{17B409B3-7EC6-49D8-847E-CFAA319E01B5}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeServicesExamples", "NodeServices\samples\NodeServicesExamples\NodeServicesExamples.csproj", "{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.NodeServices", "NodeServices\src\Microsoft.AspNetCore.NodeServices.csproj", "{40951683-DBC4-437A-BBAB-2FA7147E11EA}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SpaServices", "SpaServices", "{D6FA4ABE-E685-4EDD-8B06-D8777E76B472}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Webpack", "SpaServices\samples\Webpack\Webpack.csproj", "{121DFA13-E965-4C91-A175-19EF20DFD5AC}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices", "SpaServices\src\Microsoft.AspNetCore.SpaServices.csproj", "{D9D02772-1D53-45C3-B2CC-888F9978958C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices.Extensions", "SpaServices.Extensions\src\Microsoft.AspNetCore.SpaServices.Extensions.csproj", "{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -1391,6 +1405,66 @@ Global
|
||||||
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x64.Build.0 = Release|Any CPU
|
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.ActiveCfg = Release|Any CPU
|
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.Build.0 = Release|Any CPU
|
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -1501,6 +1575,11 @@ Global
|
||||||
{52CDD110-77DD-4C4D-8C72-4570F6EF20DD} = {7CF63806-4C4F-4C48-8922-A75113975308}
|
{52CDD110-77DD-4C4D-8C72-4570F6EF20DD} = {7CF63806-4C4F-4C48-8922-A75113975308}
|
||||||
{198FFE3B-0346-4856-A6C9-8752D51C4EB3} = {7CF63806-4C4F-4C48-8922-A75113975308}
|
{198FFE3B-0346-4856-A6C9-8752D51C4EB3} = {7CF63806-4C4F-4C48-8922-A75113975308}
|
||||||
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
|
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
|
||||||
|
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5}
|
||||||
|
{40951683-DBC4-437A-BBAB-2FA7147E11EA} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5}
|
||||||
|
{121DFA13-E965-4C91-A175-19EF20DFD5AC} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
|
||||||
|
{D9D02772-1D53-45C3-B2CC-888F9978958C} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
|
||||||
|
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA}
|
SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace NodeServicesExamples
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, INodeServices nodeServices)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, INodeServices nodeServices)
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.NodeServices
|
namespace Microsoft.AspNetCore.NodeServices
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +36,7 @@ namespace Microsoft.AspNetCore.NodeServices
|
||||||
InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds;
|
InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds;
|
||||||
WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone();
|
WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone();
|
||||||
|
|
||||||
var hostEnv = serviceProvider.GetService<IHostingEnvironment>();
|
var hostEnv = serviceProvider.GetService<IWebHostEnvironment>();
|
||||||
if (hostEnv != null)
|
if (hostEnv != null)
|
||||||
{
|
{
|
||||||
// In an ASP.NET environment, we can use the IHostingEnvironment data to auto-populate a few
|
// In an ASP.NET environment, we can use the IHostingEnvironment data to auto-populate a few
|
||||||
|
|
@ -48,7 +49,7 @@ namespace Microsoft.AspNetCore.NodeServices
|
||||||
ProjectPath = Directory.GetCurrentDirectory();
|
ProjectPath = Directory.GetCurrentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
var applicationLifetime = serviceProvider.GetService<IApplicationLifetime>();
|
var applicationLifetime = serviceProvider.GetService<IHostApplicationLifetime>();
|
||||||
if (applicationLifetime != null)
|
if (applicationLifetime != null)
|
||||||
{
|
{
|
||||||
ApplicationStoppingToken = applicationLifetime.ApplicationStopping;
|
ApplicationStoppingToken = applicationLifetime.ApplicationStopping;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -13,12 +13,12 @@ namespace RewriteSample
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IHostingEnvironment environment)
|
public Startup(IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
Environment = environment;
|
Environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostingEnvironment Environment { get; private set; }
|
public IWebHostEnvironment Environment { get; private set; }
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ namespace RewriteSample
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseRewriter();
|
app.UseRewriter();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Rewrite
|
||||||
/// <param name="options">The middleware options, containing the rules to apply.</param>
|
/// <param name="options">The middleware options, containing the rules to apply.</param>
|
||||||
public RewriteMiddleware(
|
public RewriteMiddleware(
|
||||||
RequestDelegate next,
|
RequestDelegate next,
|
||||||
IHostingEnvironment hostingEnvironment,
|
IWebHostEnvironment hostingEnvironment,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IOptions<RewriteOptions> options)
|
IOptions<RewriteOptions> options)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
@ -13,22 +12,10 @@ namespace SessionSample
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IHostingEnvironment env)
|
public Startup()
|
||||||
{
|
{
|
||||||
var builder = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(env.ContentRootPath)
|
|
||||||
.AddJsonFile("appsettings.json");
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
builder.AddUserSecrets<Startup>();
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration = builder.Build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfigurationRoot Configuration { get; set; }
|
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// Uncomment the following line to use the in-memory implementation of IDistributedCache
|
// Uncomment the following line to use the in-memory implementation of IDistributedCache
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.SpaServices;
|
||||||
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
||||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -61,9 +62,9 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
var applicationBuilder = spaBuilder.ApplicationBuilder;
|
var applicationBuilder = spaBuilder.ApplicationBuilder;
|
||||||
var serviceProvider = applicationBuilder.ApplicationServices;
|
var serviceProvider = applicationBuilder.ApplicationServices;
|
||||||
var nodeServices = GetNodeServices(serviceProvider);
|
var nodeServices = GetNodeServices(serviceProvider);
|
||||||
var applicationStoppingToken = serviceProvider.GetRequiredService<IApplicationLifetime>()
|
var applicationStoppingToken = serviceProvider.GetRequiredService<IHostApplicationLifetime>()
|
||||||
.ApplicationStopping;
|
.ApplicationStopping;
|
||||||
var applicationBasePath = serviceProvider.GetRequiredService<IHostingEnvironment>()
|
var applicationBasePath = serviceProvider.GetRequiredService<IWebHostEnvironment>()
|
||||||
.ContentRootPath;
|
.ContentRootPath;
|
||||||
var moduleExport = new JavaScriptModuleExport(capturedBootModulePath);
|
var moduleExport = new JavaScriptModuleExport(capturedBootModulePath);
|
||||||
var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>())
|
var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>())
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
||||||
string pathPrefix,
|
string pathPrefix,
|
||||||
TimeSpan requestTimeout,
|
TimeSpan requestTimeout,
|
||||||
Task<Uri> baseUriTask,
|
Task<Uri> baseUriTask,
|
||||||
IApplicationLifetime applicationLifetime)
|
IHostApplicationLifetime applicationLifetime)
|
||||||
{
|
{
|
||||||
if (!pathPrefix.StartsWith("/"))
|
if (!pathPrefix.StartsWith("/"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.SpaServices;
|
using Microsoft.AspNetCore.SpaServices;
|
||||||
using Microsoft.AspNetCore.SpaServices.Extensions.Proxy;
|
using Microsoft.AspNetCore.SpaServices.Extensions.Proxy;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -85,8 +86,8 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
{
|
{
|
||||||
var applicationLifetime = appBuilder
|
var applicationLifetime = appBuilder
|
||||||
.ApplicationServices
|
.ApplicationServices
|
||||||
.GetService(typeof(IApplicationLifetime));
|
.GetService(typeof(IHostApplicationLifetime));
|
||||||
return ((IApplicationLifetime)applicationLifetime).ApplicationStopping;
|
return ((IHostApplicationLifetime)applicationLifetime).ApplicationStopping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SpaServices
|
namespace Microsoft.AspNetCore.SpaServices
|
||||||
|
|
@ -45,7 +46,7 @@ namespace Microsoft.AspNetCore.SpaServices
|
||||||
// Try to clarify the common scenario where someone runs an application in
|
// Try to clarify the common scenario where someone runs an application in
|
||||||
// Production environment without first publishing the whole application
|
// Production environment without first publishing the whole application
|
||||||
// or at least building the SPA.
|
// or at least building the SPA.
|
||||||
var hostEnvironment = (IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment));
|
var hostEnvironment = (IWebHostEnvironment)context.RequestServices.GetService(typeof(IWebHostEnvironment));
|
||||||
if (hostEnvironment != null && hostEnvironment.IsProduction())
|
if (hostEnvironment != null && hostEnvironment.IsProduction())
|
||||||
{
|
{
|
||||||
message += "Your application is running in Production mode, so make sure it has " +
|
message += "Your application is running in Production mode, so make sure it has " +
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.SpaServices.StaticFiles
|
||||||
$"of {nameof(options)} cannot be null or empty.");
|
$"of {nameof(options)} cannot be null or empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var env = serviceProvider.GetRequiredService<IHostingEnvironment>();
|
var env = serviceProvider.GetRequiredService<IWebHostEnvironment>();
|
||||||
var absoluteRootPath = Path.Combine(
|
var absoluteRootPath = Path.Combine(
|
||||||
env.ContentRootPath,
|
env.ContentRootPath,
|
||||||
options.RootPath);
|
options.RootPath);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.NodeServices;
|
using Microsoft.AspNetCore.NodeServices;
|
||||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Webpack.ActionResults
|
namespace Webpack.ActionResults
|
||||||
{
|
{
|
||||||
|
|
@ -26,8 +27,8 @@ namespace Webpack.ActionResults
|
||||||
public override async Task ExecuteResultAsync(ActionContext context)
|
public override async Task ExecuteResultAsync(ActionContext context)
|
||||||
{
|
{
|
||||||
var nodeServices = context.HttpContext.RequestServices.GetRequiredService<INodeServices>();
|
var nodeServices = context.HttpContext.RequestServices.GetRequiredService<INodeServices>();
|
||||||
var hostEnv = context.HttpContext.RequestServices.GetRequiredService<IHostingEnvironment>();
|
var hostEnv = context.HttpContext.RequestServices.GetRequiredService<IWebHostEnvironment>();
|
||||||
var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService<IApplicationLifetime>();
|
var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService<IHostApplicationLifetime>();
|
||||||
var applicationBasePath = hostEnv.ContentRootPath;
|
var applicationBasePath = hostEnv.ContentRootPath;
|
||||||
var request = context.HttpContext.Request;
|
var request = context.HttpContext.Request;
|
||||||
var response = context.HttpContext.Response;
|
var response = context.HttpContext.Response;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Webpack
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.NodeServices;
|
using Microsoft.AspNetCore.NodeServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
{
|
{
|
||||||
|
|
@ -20,8 +21,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
|
|
||||||
public DefaultSpaPrerenderer(
|
public DefaultSpaPrerenderer(
|
||||||
INodeServices nodeServices,
|
INodeServices nodeServices,
|
||||||
IApplicationLifetime applicationLifetime,
|
IHostApplicationLifetime applicationLifetime,
|
||||||
IHostingEnvironment hostingEnvironment,
|
IWebHostEnvironment hostingEnvironment,
|
||||||
IHttpContextAccessor httpContextAccessor)
|
IHttpContextAccessor httpContextAccessor)
|
||||||
{
|
{
|
||||||
_applicationBasePath = hostingEnvironment.ContentRootPath;
|
_applicationBasePath = hostingEnvironment.ContentRootPath;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.AspNetCore.NodeServices;
|
using Microsoft.AspNetCore.NodeServices;
|
||||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
{
|
{
|
||||||
|
|
@ -31,11 +32,11 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
|
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
|
||||||
public PrerenderTagHelper(IServiceProvider serviceProvider)
|
public PrerenderTagHelper(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var hostEnv = (IHostingEnvironment)serviceProvider.GetService(typeof(IHostingEnvironment));
|
var hostEnv = (IWebHostEnvironment)serviceProvider.GetService(typeof(IWebHostEnvironment));
|
||||||
_nodeServices = (INodeServices)serviceProvider.GetService(typeof(INodeServices)) ?? _fallbackNodeServices;
|
_nodeServices = (INodeServices)serviceProvider.GetService(typeof(INodeServices)) ?? _fallbackNodeServices;
|
||||||
_applicationBasePath = hostEnv.ContentRootPath;
|
_applicationBasePath = hostEnv.ContentRootPath;
|
||||||
|
|
||||||
var applicationLifetime = (IApplicationLifetime)serviceProvider.GetService(typeof(IApplicationLifetime));
|
var applicationLifetime = (IHostApplicationLifetime)serviceProvider.GetService(typeof(IHostApplicationLifetime));
|
||||||
_applicationStoppingToken = applicationLifetime.ApplicationStopping;
|
_applicationStoppingToken = applicationLifetime.ApplicationStopping;
|
||||||
|
|
||||||
// Consider removing the following. Having it means you can get away with not putting app.AddNodeServices()
|
// Consider removing the following. Having it means you can get away with not putting app.AddNodeServices()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace StaticFilesSample
|
||||||
services.AddDirectoryBrowser();
|
services.AddDirectoryBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment host)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment host)
|
||||||
{
|
{
|
||||||
Console.WriteLine("webroot: " + host.WebRootPath);
|
Console.WriteLine("webroot: " + host.WebRootPath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
/// Creates a new instance of the DefaultFilesMiddleware.
|
/// Creates a new instance of the DefaultFilesMiddleware.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="next">The next middleware in the pipeline.</param>
|
/// <param name="next">The next middleware in the pipeline.</param>
|
||||||
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
|
/// <param name="hostingEnv">The <see cref="IWebHostEnvironment"/> used by this middleware.</param>
|
||||||
/// <param name="options">The configuration options for this middleware.</param>
|
/// <param name="options">The configuration options for this middleware.</param>
|
||||||
public DefaultFilesMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DefaultFilesOptions> options)
|
public DefaultFilesMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DefaultFilesOptions> options)
|
||||||
{
|
{
|
||||||
if (next == null)
|
if (next == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
/// Creates a new instance of the SendFileMiddleware. Using <see cref="HtmlEncoder.Default"/> instance.
|
/// Creates a new instance of the SendFileMiddleware. Using <see cref="HtmlEncoder.Default"/> instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="next">The next middleware in the pipeline.</param>
|
/// <param name="next">The next middleware in the pipeline.</param>
|
||||||
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
|
/// <param name="hostingEnv">The <see cref="IWebHostEnvironment"/> used by this middleware.</param>
|
||||||
/// <param name="options">The configuration for this middleware.</param>
|
/// <param name="options">The configuration for this middleware.</param>
|
||||||
public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
|
public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
|
||||||
: this(next, hostingEnv, HtmlEncoder.Default, options)
|
: this(next, hostingEnv, HtmlEncoder.Default, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
/// Creates a new instance of the SendFileMiddleware.
|
/// Creates a new instance of the SendFileMiddleware.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="next">The next middleware in the pipeline.</param>
|
/// <param name="next">The next middleware in the pipeline.</param>
|
||||||
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
|
/// <param name="hostingEnv">The <see cref="IWebHostEnvironment"/> used by this middleware.</param>
|
||||||
/// <param name="encoder">The <see cref="HtmlEncoder"/> used by the default <see cref="HtmlDirectoryFormatter"/>.</param>
|
/// <param name="encoder">The <see cref="HtmlEncoder"/> used by the default <see cref="HtmlDirectoryFormatter"/>.</param>
|
||||||
/// <param name="options">The configuration for this middleware.</param>
|
/// <param name="options">The configuration for this middleware.</param>
|
||||||
public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, HtmlEncoder encoder, IOptions<DirectoryBrowserOptions> options)
|
public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, HtmlEncoder encoder, IOptions<DirectoryBrowserOptions> options)
|
||||||
{
|
{
|
||||||
if (next == null)
|
if (next == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
{
|
{
|
||||||
internal static class Helpers
|
internal static class Helpers
|
||||||
{
|
{
|
||||||
internal static IFileProvider ResolveFileProvider(IHostingEnvironment hostingEnv)
|
internal static IFileProvider ResolveFileProvider(IWebHostEnvironment hostingEnv)
|
||||||
{
|
{
|
||||||
if (hostingEnv.WebRootFileProvider == null) {
|
if (hostingEnv.WebRootFileProvider == null) {
|
||||||
throw new InvalidOperationException("Missing FileProvider.");
|
throw new InvalidOperationException("Missing FileProvider.");
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
/// Creates a new instance of the StaticFileMiddleware.
|
/// Creates a new instance of the StaticFileMiddleware.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="next">The next middleware in the pipeline.</param>
|
/// <param name="next">The next middleware in the pipeline.</param>
|
||||||
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
|
/// <param name="hostingEnv">The <see cref="IWebHostEnvironment"/> used by this middleware.</param>
|
||||||
/// <param name="options">The configuration options.</param>
|
/// <param name="options">The configuration options.</param>
|
||||||
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
|
/// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
|
||||||
public StaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<StaticFileOptions> options, ILoggerFactory loggerFactory)
|
public StaticFileMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<StaticFileOptions> options, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
if (next == null)
|
if (next == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
|
|
||||||
using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel)))
|
using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel)))
|
||||||
{
|
{
|
||||||
var hostingEnvironment = server.Services.GetService<IHostingEnvironment>();
|
var hostingEnvironment = server.Services.GetService<IWebHostEnvironment>();
|
||||||
|
|
||||||
using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) })
|
using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) })
|
||||||
{
|
{
|
||||||
|
|
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
|
|
||||||
using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel)))
|
using (var server = builder.Start(TestUrlHelper.GetTestUrl(ServerType.Kestrel)))
|
||||||
{
|
{
|
||||||
var hostingEnvironment = server.Services.GetService<IHostingEnvironment>();
|
var hostingEnvironment = server.Services.GetService<IWebHostEnvironment>();
|
||||||
|
|
||||||
using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) })
|
using (var client = new HttpClient { BaseAddress = new Uri(server.GetAddress()) })
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace AutobahnTestApp
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
app.UseWebSockets();
|
app.UseWebSockets();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -458,7 +458,7 @@ namespace MusicStore.Controllers
|
||||||
|
|
||||||
// TODO: Currently SignInManager.SignOut does not sign out OpenIdc and does not have a way to pass in a specific
|
// TODO: Currently SignInManager.SignOut does not sign out OpenIdc and does not have a way to pass in a specific
|
||||||
// AuthType to sign out.
|
// AuthType to sign out.
|
||||||
var appEnv = HttpContext.RequestServices.GetService<IHostingEnvironment>();
|
var appEnv = HttpContext.RequestServices.GetService<IWebHostEnvironment>();
|
||||||
if (appEnv.EnvironmentName.StartsWith("OpenIdConnect"))
|
if (appEnv.EnvironmentName.StartsWith("OpenIdConnect"))
|
||||||
{
|
{
|
||||||
return new SignOutResult("OpenIdConnect", new AuthenticationProperties
|
return new SignOutResult("OpenIdConnect", new AuthenticationProperties
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -9,9 +9,9 @@ namespace MusicStore.Mocks.OpenIdConnect
|
||||||
{
|
{
|
||||||
internal class OpenIdConnectBackChannelHttpHandler : HttpMessageHandler
|
internal class OpenIdConnectBackChannelHttpHandler : HttpMessageHandler
|
||||||
{
|
{
|
||||||
private IHostingEnvironment _env;
|
private IWebHostEnvironment _env;
|
||||||
|
|
||||||
public OpenIdConnectBackChannelHttpHandler(IHostingEnvironment env)
|
public OpenIdConnectBackChannelHttpHandler(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
_env = env;
|
_env = env;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace MusicStore
|
||||||
{
|
{
|
||||||
private readonly Platform _platform;
|
private readonly Platform _platform;
|
||||||
|
|
||||||
public StartupOpenIdConnectTesting(IHostingEnvironment env)
|
public StartupOpenIdConnectTesting(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
||||||
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
||||||
|
|
@ -40,7 +40,7 @@ namespace MusicStore
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; private set; }
|
public IConfiguration Configuration { get; private set; }
|
||||||
public IHostingEnvironment Env { get; }
|
public IWebHostEnvironment Env { get; }
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace MusicStore
|
||||||
{
|
{
|
||||||
private readonly Platform _platform;
|
private readonly Platform _platform;
|
||||||
|
|
||||||
public StartupSocialTesting(IHostingEnvironment hostingEnvironment)
|
public StartupSocialTesting(IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
||||||
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ namespace MusicStore.Models
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static async Task CreateAdminUser(IServiceProvider serviceProvider)
|
private static async Task CreateAdminUser(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var env = serviceProvider.GetService<IHostingEnvironment>();
|
var env = serviceProvider.GetService<IWebHostEnvironment>();
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(env.ContentRootPath)
|
.SetBasePath(env.ContentRootPath)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace MusicStore
|
||||||
{
|
{
|
||||||
private readonly Platform _platform;
|
private readonly Platform _platform;
|
||||||
|
|
||||||
public Startup(IHostingEnvironment hostingEnvironment)
|
public Startup(IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
||||||
// is found in both the registered sources, then the later source will win. By this way a Local config
|
// is found in both the registered sources, then the later source will win. By this way a Local config
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace MusicStore
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StartupNtlmAuthentication
|
public class StartupNtlmAuthentication
|
||||||
{
|
{
|
||||||
public StartupNtlmAuthentication(IHostingEnvironment hostingEnvironment)
|
public StartupNtlmAuthentication(IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
||||||
// is found in both the registered sources, then the later source will win. By this way a Local config
|
// is found in both the registered sources, then the later source will win. By this way a Local config
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace MusicStore
|
||||||
{
|
{
|
||||||
private readonly Platform _platform;
|
private readonly Platform _platform;
|
||||||
|
|
||||||
public StartupOpenIdConnect(IHostingEnvironment hostingEnvironment)
|
public StartupOpenIdConnect(IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
{
|
||||||
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
// Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1'
|
||||||
// is found in both the registered sources, then the later source will win. By this way a Local config can
|
// is found in both the registered sources, then the later source will win. By this way a Local config can
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
manager = new ApplicationPartManager();
|
manager = new ApplicationPartManager();
|
||||||
|
|
||||||
var environment = GetServiceFromCollection<IHostingEnvironment>(services);
|
var environment = GetServiceFromCollection<IWebHostEnvironment>(services);
|
||||||
var entryAssemblyName = environment?.ApplicationName;
|
var entryAssemblyName = environment?.ApplicationName;
|
||||||
if (string.IsNullOrEmpty(entryAssemblyName))
|
if (string.IsNullOrEmpty(entryAssemblyName))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
{
|
{
|
||||||
public class VirtualFileResultExecutor : FileResultExecutorBase, IActionResultExecutor<VirtualFileResult>
|
public class VirtualFileResultExecutor : FileResultExecutorBase, IActionResultExecutor<VirtualFileResult>
|
||||||
{
|
{
|
||||||
private readonly IHostingEnvironment _hostingEnvironment;
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
|
|
||||||
public VirtualFileResultExecutor(ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment)
|
public VirtualFileResultExecutor(ILoggerFactory loggerFactory, IWebHostEnvironment hostingEnvironment)
|
||||||
: base(CreateLogger<VirtualFileResultExecutor>(loggerFactory))
|
: base(CreateLogger<VirtualFileResultExecutor>(loggerFactory))
|
||||||
{
|
{
|
||||||
if (hostingEnvironment == null)
|
if (hostingEnvironment == null)
|
||||||
|
|
|
||||||
|
|
@ -152,9 +152,9 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
var environment = new Mock<IHostingEnvironment>(MockBehavior.Strict);
|
var environment = new Mock<IWebHostEnvironment>(MockBehavior.Strict);
|
||||||
environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable();
|
environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable();
|
||||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var builder = services.AddMvcCore();
|
var builder = services.AddMvcCore();
|
||||||
|
|
@ -173,12 +173,12 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
var environment = new Mock<IHostingEnvironment>(MockBehavior.Strict);
|
var environment = new Mock<IWebHostEnvironment>(MockBehavior.Strict);
|
||||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||||
|
|
||||||
environment = new Mock<IHostingEnvironment>(MockBehavior.Strict);
|
environment = new Mock<IWebHostEnvironment>(MockBehavior.Strict);
|
||||||
environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable();
|
environment.SetupGet(e => e.ApplicationName).Returns((string)null).Verifiable();
|
||||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var builder = services.AddMvcCore();
|
var builder = services.AddMvcCore();
|
||||||
|
|
@ -196,11 +196,11 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
var environment = new Mock<IHostingEnvironment>(MockBehavior.Strict);
|
var environment = new Mock<IWebHostEnvironment>(MockBehavior.Strict);
|
||||||
var assemblyName = typeof(MvcCoreServiceCollectionExtensionsTest).GetTypeInfo().Assembly.GetName();
|
var assemblyName = typeof(MvcCoreServiceCollectionExtensionsTest).GetTypeInfo().Assembly.GetName();
|
||||||
var applicationName = assemblyName.FullName;
|
var applicationName = assemblyName.FullName;
|
||||||
environment.SetupGet(e => e.ApplicationName).Returns(applicationName).Verifiable();
|
environment.SetupGet(e => e.ApplicationName).Returns(applicationName).Verifiable();
|
||||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var builder = services.AddMvcCore();
|
var builder = services.AddMvcCore();
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue