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
|
||||
|
||||
@inject IHostingEnvironment Environment
|
||||
@inject IWebHostEnvironment Environment
|
||||
@inject ICompositeViewEngine Engine
|
||||
|
||||
@{
|
||||
|
|
@ -10,4 +10,4 @@
|
|||
{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@using Microsoft.AspNetCore.Hosting
|
||||
@using Microsoft.AspNetCore.Hosting
|
||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||
|
||||
@inject IHostingEnvironment Environment
|
||||
@inject IWebHostEnvironment Environment
|
||||
@inject ICompositeViewEngine Engine
|
||||
|
||||
@{
|
||||
|
|
@ -10,4 +10,4 @@
|
|||
{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
|
@ -14,7 +14,7 @@ namespace AzureAD.WebSite
|
|||
services.AddMvc();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseAuthentication();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Blazor.Cli.Server
|
|||
|
||||
private static string FindClientAssemblyPath(IApplicationBuilder app)
|
||||
{
|
||||
var env = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
||||
var contentRoot = env.ContentRootPath;
|
||||
var binDir = FindClientBinDir(contentRoot);
|
||||
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.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
|
@ -8,7 +8,7 @@ namespace MonoSanity
|
|||
{
|
||||
public class Startup
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseFileServer(new FileServerOptions { EnableDefaultFiles = true });
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Microsoft.Net.Http.Headers;
|
|||
using System.Net.Mime;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
// TODO: Make the .blazor.config file contents sane
|
||||
// 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.
|
||||
var env = (IHostingEnvironment)app.ApplicationServices.GetService(typeof(IHostingEnvironment));
|
||||
var env = (IWebHostEnvironment)app.ApplicationServices.GetService(typeof(IWebHostEnvironment));
|
||||
var config = BlazorConfig.Read(options.ClientAssemblyPath);
|
||||
|
||||
if (env.IsDevelopment() && config.EnableAutoRebuilding)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ namespace ComponentsApp.Server
|
|||
{
|
||||
public class DefaultWeatherForecastService : WeatherForecastService
|
||||
{
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
|
||||
public DefaultWeatherForecastService(IHostingEnvironment hostingEnvironment)
|
||||
public DefaultWeatherForecastService(IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Builder;
|
|||
using Microsoft.AspNetCore.Components.Server.Circuits;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
|
||||
namespace ComponentsApp.Server
|
||||
{
|
||||
|
|
@ -17,7 +19,7 @@ namespace ComponentsApp.Server
|
|||
services.AddSingleton<WeatherForecastService, DefaultWeatherForecastService>();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace TestServer
|
||||
{
|
||||
|
|
@ -27,7 +28,7 @@ namespace TestServer
|
|||
}
|
||||
|
||||
// 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())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.DataProtection.Internal
|
||||
{
|
||||
internal class HostingApplicationDiscriminator : IApplicationDiscriminator
|
||||
{
|
||||
private readonly IHostingEnvironment _hosting;
|
||||
private readonly IHostEnvironment _hosting;
|
||||
|
||||
// the optional constructor for when IHostingEnvironment is not available from DI
|
||||
public HostingApplicationDiscriminator()
|
||||
{
|
||||
}
|
||||
|
||||
public HostingApplicationDiscriminator(IHostingEnvironment hosting)
|
||||
public HostingApplicationDiscriminator(IHostEnvironment hosting)
|
||||
{
|
||||
_hosting = hosting;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using Microsoft.AspNetCore.DataProtection.Infrastructure;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
public void GetApplicationUniqueIdentifierFromHosting(string contentRootPath, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var mockEnvironment = new Mock<IHostingEnvironment>();
|
||||
var mockEnvironment = new Mock<IHostEnvironment>();
|
||||
mockEnvironment.Setup(o => o.ContentRootPath).Returns(contentRootPath);
|
||||
|
||||
var services = new ServiceCollection()
|
||||
|
|
@ -47,7 +48,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
var mockAppDiscriminator = new Mock<IApplicationDiscriminator>();
|
||||
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"));
|
||||
|
||||
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.
|
||||
|
||||
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) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
@ -118,9 +119,9 @@ namespace Microsoft.AspNetCore
|
|||
/// <remarks>
|
||||
/// 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,
|
||||
/// set the <see cref="IHostingEnvironment.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 User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||
/// 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="IHostEnvironment.EnvironmentName"/>].json',
|
||||
/// 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,
|
||||
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||
/// and enable IIS integration.
|
||||
|
|
@ -135,9 +136,9 @@ namespace Microsoft.AspNetCore
|
|||
/// <remarks>
|
||||
/// 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,
|
||||
/// set the <see cref="IHostingEnvironment.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 User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||
/// 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="IHostEnvironment.EnvironmentName"/>].json',
|
||||
/// 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 supplied command line args,
|
||||
/// configure the <see cref="ILoggerFactory"/> to log to the console and debug output,
|
||||
|
|
@ -235,9 +236,9 @@ namespace Microsoft.AspNetCore
|
|||
/// <remarks>
|
||||
/// 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,
|
||||
/// set the <see cref="IHostingEnvironment.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 User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
|
||||
/// 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="IHostEnvironment.EnvironmentName"/>].json',
|
||||
/// 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 supplied command line args,
|
||||
/// 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.
|
||||
|
||||
using System;
|
||||
|
|
@ -30,7 +30,7 @@ namespace CreateDefaultBuilderApp
|
|||
}))
|
||||
.Configure(app => app.Run(context =>
|
||||
{
|
||||
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IHostingEnvironment>();
|
||||
var hostingEnvironment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
||||
return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName);
|
||||
}))
|
||||
.Build().Run();
|
||||
|
|
@ -78,4 +78,4 @@ namespace CreateDefaultBuilderApp
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.HostFiltering;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace CreateDefaultBuilderOfTApp
|
||||
|
|
@ -40,7 +41,7 @@ namespace CreateDefaultBuilderOfTApp
|
|||
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);
|
||||
}))
|
||||
.Build()
|
||||
|
|
@ -89,4 +90,4 @@ namespace CreateDefaultBuilderOfTApp
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace StartRequestDelegateUrlApp
|
||||
{
|
||||
|
|
@ -20,7 +20,7 @@ namespace StartRequestDelegateUrlApp
|
|||
using (var host = WebHost.Start("http://127.0.0.1:0", async context =>
|
||||
{
|
||||
// Respond with the ApplicationName.
|
||||
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||
var env = context.RequestServices.GetRequiredService<IHostEnvironment>();
|
||||
await context.Response.WriteAsync(env.ApplicationName);
|
||||
messageSent.Set();
|
||||
}))
|
||||
|
|
@ -40,4 +40,4 @@ namespace StartRequestDelegateUrlApp
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace StartRequestDelegateUrlApp
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ namespace StartRequestDelegateUrlApp
|
|||
using (var host = WebHost.Start("http://127.0.0.1:0", router =>
|
||||
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);
|
||||
messageSent.Set();
|
||||
})))
|
||||
|
|
@ -40,4 +40,4 @@ namespace StartRequestDelegateUrlApp
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace StartWithIApplicationBuilderUrlApp
|
||||
{
|
||||
|
|
@ -22,7 +23,7 @@ namespace StartWithIApplicationBuilderUrlApp
|
|||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
var env = context.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||
var env = context.RequestServices.GetRequiredService<IHostEnvironment>();
|
||||
await context.Response.WriteAsync(env.ApplicationName);
|
||||
messageSent.Set();
|
||||
});
|
||||
|
|
@ -42,4 +43,4 @@ namespace StartWithIApplicationBuilderUrlApp
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -77,4 +77,5 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
/// <summary>
|
||||
/// Allows consumers to perform cleanup during a graceful shutdown.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use Microsoft.Extensions.Hosting.IHostApplicationLifetime instead.", error: false)]
|
||||
public interface IApplicationLifetime
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
/// <summary>
|
||||
/// Provides information about the web hosting environment an application is running in.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use IWebHostEnvironment instead.", error: false)]
|
||||
public interface IHostingEnvironment
|
||||
{
|
||||
/// <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.
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
public class WebHostBuilderContext
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IHostingEnvironment" /> initialized by the <see cref="IWebHost" />.
|
||||
/// The <see cref="IWebHostEnvironment" /> initialized by the <see cref="IWebHost" />.
|
||||
/// </summary>
|
||||
public IHostingEnvironment HostingEnvironment { get; set; }
|
||||
public IWebHostEnvironment HostingEnvironment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||
{
|
||||
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime;
|
||||
public GenericWebHostApplicationLifetime(Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime)
|
||||
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
private readonly IHostApplicationLifetime _applicationLifetime;
|
||||
public GenericWebHostApplicationLifetime(IHostApplicationLifetime applicationLifetime)
|
||||
{
|
||||
_applicationLifetime = applicationLifetime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,10 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
|
||||
// Add the IHostingEnvironment and IApplicationLifetime from Microsoft.AspNetCore.Hosting
|
||||
services.AddSingleton(webhostContext.HostingEnvironment);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
services.AddSingleton((AspNetCore.Hosting.IHostingEnvironment)webhostContext.HostingEnvironment);
|
||||
services.AddSingleton<IApplicationLifetime, GenericWebHostApplicationLifetime>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
services.Configure<GenericWebHostServiceOptions>(options =>
|
||||
{
|
||||
|
|
@ -318,14 +321,12 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
if (!context.Properties.TryGetValue(typeof(WebHostBuilderContext), out var contextVal))
|
||||
{
|
||||
var options = new WebHostOptions(context.Configuration, Assembly.GetEntryAssembly()?.GetName().Name);
|
||||
var hostingEnvironment = new HostingEnvironment();
|
||||
hostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options);
|
||||
|
||||
var webHostBuilderContext = new WebHostBuilderContext
|
||||
{
|
||||
Configuration = context.Configuration,
|
||||
HostingEnvironment = hostingEnvironment
|
||||
HostingEnvironment = new HostingEnvironment(),
|
||||
};
|
||||
webHostBuilderContext.HostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options);
|
||||
context.Properties[typeof(WebHostBuilderContext)] = webHostBuilderContext;
|
||||
context.Properties[typeof(WebHostOptions)] = options;
|
||||
return webHostBuilderContext;
|
||||
|
|
@ -361,7 +362,13 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
public object GetService(Type serviceType)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
IApplicationBuilderFactory applicationBuilderFactory,
|
||||
IEnumerable<IStartupFilter> startupFilters,
|
||||
IConfiguration configuration,
|
||||
IHostingEnvironment hostingEnvironment)
|
||||
IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
Options = options.Value;
|
||||
Server = server;
|
||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
public IApplicationBuilderFactory ApplicationBuilderFactory { get; }
|
||||
public IEnumerable<IStartupFilter> StartupFilters { get; }
|
||||
public IConfiguration Configuration { get; }
|
||||
public IHostingEnvironment HostingEnvironment { get; }
|
||||
public IWebHostEnvironment HostingEnvironment { get; }
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||
|
|
@ -11,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
/// Allows consumers to perform cleanup during a graceful shutdown.
|
||||
/// </summary>
|
||||
#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
|
||||
{
|
||||
private readonly CancellationTokenSource _startedSource = new CancellationTokenSource();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.FileProviders;
|
|||
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||
{
|
||||
#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
|
||||
{
|
||||
public string EnvironmentName { get; set; } = Hosting.EnvironmentName.Production;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,62 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
{
|
||||
public static class HostingEnvironmentExtensions
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
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)
|
||||
{
|
||||
|
|
@ -62,4 +117,4 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
hostingEnvironment.EnvironmentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.StackTrace.Sources;
|
||||
|
||||
|
|
@ -76,14 +77,16 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
_options = options;
|
||||
_applicationServiceCollection = appServices;
|
||||
_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
|
||||
_applicationServiceCollection.AddSingleton(sp =>
|
||||
{
|
||||
_applicationServiceCollection.AddSingleton(services
|
||||
=> services.GetService<ApplicationLifetime>() as IHostApplicationLifetime);
|
||||
#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
|
||||
});
|
||||
_applicationServiceCollection.AddSingleton<HostedServiceExecutor>();
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +144,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
|
||||
var application = BuildApplication();
|
||||
|
||||
_applicationLifetime = _applicationServices.GetRequiredService<IApplicationLifetime>() as ApplicationLifetime;
|
||||
_applicationLifetime = _applicationServices.GetRequiredService<ApplicationLifetime>();
|
||||
_hostedServiceExecutor = _applicationServices.GetRequiredService<HostedServiceExecutor>();
|
||||
var diagnosticSource = _applicationServices.GetRequiredService<DiagnosticListener>();
|
||||
var httpContextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
|
||||
|
|
@ -238,7 +241,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
|
|||
EnsureServer();
|
||||
|
||||
// Generate an HTML error page.
|
||||
var hostingEnv = _applicationServices.GetRequiredService<IHostingEnvironment>();
|
||||
var hostingEnv = _applicationServices.GetRequiredService<IHostEnvironment>();
|
||||
var showDetailedErrors = hostingEnv.IsDevelopment() || _options.DetailedErrors;
|
||||
|
||||
var model = new ErrorPageModel
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
|
||||
|
|
@ -248,13 +249,15 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, AppContext.BaseDirectory);
|
||||
|
||||
// Initialize the hosting environment
|
||||
_hostingEnvironment.Initialize(contentRootPath, _options);
|
||||
((IWebHostEnvironment)_hostingEnvironment).Initialize(contentRootPath, _options);
|
||||
_context.HostingEnvironment = _hostingEnvironment;
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton(_options);
|
||||
services.AddSingleton<IHostingEnvironment>(_hostingEnvironment);
|
||||
services.AddSingleton<IWebHostEnvironment>(_hostingEnvironment);
|
||||
services.AddSingleton<IHostEnvironment>(_hostingEnvironment);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
services.AddSingleton<AspNetCore.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
||||
services.AddSingleton<Extensions.Hosting.IHostingEnvironment>(_hostingEnvironment);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
services.AddSingleton(_context);
|
||||
|
|
@ -295,7 +298,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
services.AddSingleton(typeof(IStartup), sp =>
|
||||
{
|
||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
||||
var hostingEnvironment = sp.GetRequiredService<IHostEnvironment>();
|
||||
var methods = StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName);
|
||||
return new ConventionBasedStartup(methods);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting.Internal;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
|
|
@ -76,7 +77,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
services.AddSingleton(typeof(IStartup), sp =>
|
||||
{
|
||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
||||
var hostingEnvironment = sp.GetRequiredService<IHostEnvironment>();
|
||||
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.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting.Internal;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
{
|
||||
|
|
@ -105,7 +106,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
await host.StartAsync(token);
|
||||
|
||||
var hostingEnvironment = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnvironment = host.Services.GetService<IHostEnvironment>();
|
||||
var options = host.Services.GetRequiredService<WebHostOptions>();
|
||||
|
||||
if (!options.SuppressStatusMessages)
|
||||
|
|
@ -146,11 +147,11 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
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 =>
|
||||
{
|
||||
((IApplicationLifetime)state).StopApplication();
|
||||
((IHostApplicationLifetime)state).StopApplication();
|
||||
},
|
||||
applicationLifetime);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.Tests.Fakes
|
||||
{
|
||||
public class StartupWithHostingEnvironment
|
||||
{
|
||||
public StartupWithHostingEnvironment(IHostingEnvironment env)
|
||||
public StartupWithHostingEnvironment(IHostEnvironment env)
|
||||
{
|
||||
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]
|
||||
public void SetsFullPathToWwwroot()
|
||||
{
|
||||
var env = new HostingEnvironment();
|
||||
IWebHostEnvironment env = new HostingEnvironment();
|
||||
|
||||
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { WebRoot = "testroot" });
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
|||
[Fact]
|
||||
public void DefaultsToWwwrootSubdir()
|
||||
{
|
||||
var env = new HostingEnvironment();
|
||||
IWebHostEnvironment env = new HostingEnvironment();
|
||||
|
||||
env.Initialize(Path.GetFullPath("testroot"), new WebHostOptions());
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
|||
[Fact]
|
||||
public void DefaultsToNullFileProvider()
|
||||
{
|
||||
var env = new HostingEnvironment();
|
||||
IWebHostEnvironment env = new HostingEnvironment();
|
||||
|
||||
env.Initialize(Path.GetFullPath(Path.Combine("testroot", "wwwroot")), new WebHostOptions());
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
|
|||
[Fact]
|
||||
public void OverridesEnvironmentFromConfig()
|
||||
{
|
||||
var env = new HostingEnvironment();
|
||||
IWebHostEnvironment env = new HostingEnvironment();
|
||||
env.EnvironmentName = "SomeName";
|
||||
|
||||
env.Initialize(Path.GetFullPath("."), new WebHostOptions() { Environment = "NewName" });
|
||||
|
|
|
|||
|
|
@ -98,14 +98,14 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(DefaultWebHostBuildersWithConfig))]
|
||||
public async Task IApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder)
|
||||
public async Task IHostApplicationLifetimeRegisteredEvenWhenStartupCtorThrows_Fallback(IWebHostBuilder builder)
|
||||
{
|
||||
var server = new TestServer();
|
||||
var host = builder.UseServer(server).UseStartup<StartupCtorThrows>().Build();
|
||||
using (host)
|
||||
{
|
||||
await host.StartAsync();
|
||||
var services = host.Services.GetServices<IApplicationLifetime>();
|
||||
var services = host.Services.GetServices<IHostApplicationLifetime>();
|
||||
Assert.NotNull(services);
|
||||
Assert.NotEmpty(services);
|
||||
|
||||
|
|
@ -551,8 +551,10 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||
.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
|
||||
Assert.Equal(expected, host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().EnvironmentName);
|
||||
Assert.Equal(expected, host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().EnvironmentName);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
|
@ -598,8 +600,10 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||
.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
|
||||
Assert.Equal("/", host.Services.GetService<AspNetCore.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||
Assert.Equal("/", host.Services.GetService<Extensions.Hosting.IHostingEnvironment>().ContentRootPath);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
|
@ -615,9 +619,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||
.Build())
|
||||
{
|
||||
var basePath = host.Services.GetRequiredService<IHostingEnvironment>().ContentRootPath;
|
||||
var basePath = host.Services.GetRequiredService<IHostEnvironment>().ContentRootPath;
|
||||
#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
|
||||
|
||||
Assert.True(Path.IsPathRooted(basePath));
|
||||
|
|
@ -638,9 +642,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -666,9 +670,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup(typeof(Startup).Assembly.GetName().Name)
|
||||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||
#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
|
||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
Assert.Equal(typeof(Startup).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||
|
|
@ -684,9 +688,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup<StartupNoServicesNoInterface>()
|
||||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||
#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
|
||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv2.ApplicationName);
|
||||
|
|
@ -702,7 +706,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup(typeof(StartupNoServicesNoInterface))
|
||||
.Build();
|
||||
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||
Assert.Equal(typeof(StartupNoServicesNoInterface).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
}
|
||||
|
||||
|
|
@ -715,7 +719,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Configure(app => { })
|
||||
.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
|
||||
Assert.Equal(typeof(WebHostBuilderTests).Assembly.GetName().Name, hostingEnv.ApplicationName);
|
||||
|
|
@ -731,7 +735,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Configure(app => { })
|
||||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
||||
}
|
||||
}
|
||||
|
|
@ -745,7 +749,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Configure(StaticConfigureMethod)
|
||||
.Build())
|
||||
{
|
||||
var hostingEnv = host.Services.GetService<IHostingEnvironment>();
|
||||
var hostingEnv = host.Services.GetService<IHostEnvironment>();
|
||||
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", hostingEnv.ApplicationName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
#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
|
||||
var server = (FakeServer)host.Services.GetRequiredService<IServer>();
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseStartup("Microsoft.AspNetCore.Hosting.Tests")
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
var applicationStartedEvent = new ManualResetEventSlim(false);
|
||||
var applicationStoppingEvent = new ManualResetEventSlim(false);
|
||||
var applicationStoppedEvent = new ManualResetEventSlim(false);
|
||||
|
|
@ -416,9 +416,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseFakeServer()
|
||||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||
#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
|
||||
|
||||
Assert.False(applicationLifetime.ApplicationStarted.IsCancellationRequested);
|
||||
|
|
@ -437,9 +437,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.UseFakeServer()
|
||||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||
#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
|
||||
|
||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||
|
|
@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
lifetime.StopApplication();
|
||||
|
||||
await host.StartAsync();
|
||||
|
|
@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
lifetime.StopApplication();
|
||||
|
||||
await host.StartAsync();
|
||||
|
|
@ -562,7 +562,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
lifetime.StopApplication();
|
||||
|
||||
var svc = (TestHostedService)host.Services.GetRequiredService<IHostedService>();
|
||||
|
|
@ -605,7 +605,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
|
||||
Assert.Equal(0, startedCalls);
|
||||
|
||||
|
|
@ -658,7 +658,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var lifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
|
||||
Assert.Equal(0, startedCalls);
|
||||
await host.StartAsync();
|
||||
|
|
@ -687,9 +687,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
})
|
||||
.Build())
|
||||
{
|
||||
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
|
||||
var applicationLifetime = host.Services.GetService<IHostApplicationLifetime>();
|
||||
#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
|
||||
|
||||
var started = RegisterCallbacksThatThrow(applicationLifetime.ApplicationStarted);
|
||||
|
|
@ -721,9 +721,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
.Build())
|
||||
{
|
||||
await host.StartAsync();
|
||||
var env = host.Services.GetService<IHostingEnvironment>();
|
||||
var env = host.Services.GetService<IHostEnvironment>();
|
||||
#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
|
||||
Assert.Equal("Changed", env.EnvironmentName);
|
||||
Assert.Equal("Changed", env2.EnvironmentName);
|
||||
|
|
@ -808,9 +808,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
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
|
||||
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
|
||||
Assert.Equal(EnvironmentName.Production, env.EnvironmentName);
|
||||
Assert.Equal(EnvironmentName.Production, env2.EnvironmentName);
|
||||
|
|
@ -831,9 +831,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
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
|
||||
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
|
||||
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())
|
||||
{
|
||||
var env = host.Services.GetService<IHostingEnvironment>();
|
||||
var env = host.Services.GetService<IWebHostEnvironment>();
|
||||
Assert.Equal(Path.GetFullPath("testroot"), env.WebRootPath);
|
||||
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())
|
||||
{
|
||||
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("producTion"));
|
||||
}
|
||||
|
|
@ -1034,10 +1040,12 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
private class TestHostedService : IHostedService, IDisposable
|
||||
{
|
||||
private readonly IApplicationLifetime _lifetime;
|
||||
private readonly IHostApplicationLifetime _lifetime;
|
||||
|
||||
#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
|
||||
{
|
||||
_lifetime = lifetime;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.ServiceProcess;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.WindowsServices
|
||||
{
|
||||
|
|
@ -44,7 +45,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices
|
|||
// race conditions.
|
||||
_host
|
||||
.Services
|
||||
.GetRequiredService<IApplicationLifetime>()
|
||||
.GetRequiredService<IHostApplicationLifetime>()
|
||||
.ApplicationStopping
|
||||
.Register(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Http.Features;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
{
|
||||
|
|
@ -25,7 +26,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
var host = new WebHostBuilder().UseServer(new FakeServer()).Configure(x => { }).Build();
|
||||
var webHostService = new WebHostService(host);
|
||||
var applicationLifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
|
||||
applicationLifetime.StopApplication();
|
||||
webHostService.Start();
|
||||
|
|
@ -39,7 +40,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
{
|
||||
var host = new WebHostBuilder().UseServer( new FakeServer() ).Configure( x => { } ).Build();
|
||||
var webHostService = new WebHostService(host);
|
||||
var applicationLifetime = host.Services.GetRequiredService<IApplicationLifetime>();
|
||||
var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
|
||||
webHostService.Start();
|
||||
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.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace IStartupInjectionAssemblyName
|
||||
{
|
||||
|
|
@ -14,7 +13,7 @@ namespace IStartupInjectionAssemblyName
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var webHost = CreateWebHostBuilder(args).Build();
|
||||
var applicationName = webHost.Services.GetRequiredService<IHostingEnvironment>().ApplicationName;
|
||||
var applicationName = webHost.Services.GetRequiredService<IHostEnvironment>().ApplicationName;
|
||||
Console.WriteLine(applicationName);
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.TestSites
|
||||
{
|
||||
public class StartupShutdown
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationLifetime lifetime)
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostApplicationLifetime lifetime)
|
||||
{
|
||||
lifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using ApiAuthSample.Data;
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
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.
|
||||
|
||||
using System;
|
||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Authentication
|
|||
var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme;
|
||||
|
||||
var localApiDescriptor = sp.GetRequiredService<IIdentityServerJwtDescriptor>();
|
||||
var hostingEnvironment = sp.GetRequiredService<IHostingEnvironment>();
|
||||
var hostingEnvironment = sp.GetRequiredService<IWebHostEnvironment>();
|
||||
var apiName = hostingEnvironment.ApplicationName + IdentityServerJwtNameSuffix;
|
||||
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -8,12 +8,12 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
|
|||
{
|
||||
internal class IdentityServerJwtDescriptor : IIdentityServerJwtDescriptor
|
||||
{
|
||||
public IdentityServerJwtDescriptor(IHostingEnvironment environment)
|
||||
public IdentityServerJwtDescriptor(IWebHostEnvironment environment)
|
||||
{
|
||||
Environment = environment;
|
||||
}
|
||||
|
||||
public IHostingEnvironment Environment { get; }
|
||||
public IWebHostEnvironment Environment { get; }
|
||||
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.ApiAuthorization.IdentityServer.Configuration
|
|||
public void LocalApiDescriptor_DefinesApiResources()
|
||||
{
|
||||
// Arrange
|
||||
var environment = new Mock<IHostingEnvironment>();
|
||||
var environment = new Mock<IWebHostEnvironment>();
|
||||
environment.SetupGet(e => e.ApplicationName).Returns("Test");
|
||||
var descriptor = new IdentityServerJwtDescriptor(environment.Object);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
@using Microsoft.AspNetCore.Hosting
|
||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||
@inject IHostingEnvironment Environment
|
||||
@inject IWebHostEnvironment Environment
|
||||
@inject ICompositeViewEngine Engine
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
@using Microsoft.AspNetCore.Hosting
|
||||
@using Microsoft.AspNetCore.Hosting
|
||||
@using Microsoft.AspNetCore.Mvc.ViewEngines
|
||||
@inject IHostingEnvironment Environment
|
||||
@inject IWebHostEnvironment Environment
|
||||
@inject ICompositeViewEngine Engine
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ namespace Microsoft.AspNetCore.Identity.UI
|
|||
private const string IdentityUIDefaultAreaName = "Identity";
|
||||
|
||||
public IdentityDefaultUIConfigureOptions(
|
||||
IHostingEnvironment environment,
|
||||
IWebHostEnvironment environment,
|
||||
IOptions<DefaultUIOptions> uiOptions)
|
||||
{
|
||||
Environment = environment;
|
||||
UiOptions = uiOptions;
|
||||
}
|
||||
|
||||
public IHostingEnvironment Environment { get; }
|
||||
public IWebHostEnvironment Environment { get; }
|
||||
public IOptions<DefaultUIOptions> UiOptions { get; }
|
||||
|
||||
public void PostConfigure(string name, RazorPagesOptions options)
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace IdentitySample.DefaultUI
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
public Startup(IWebHostEnvironment env)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace IdentitySample
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
public Startup(IWebHostEnvironment env)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
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.
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
|
@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Diagnostics;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace SampleDestination
|
|||
services.AddRouting();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseRouting(routing =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace SampleDestination
|
|||
services.AddCors();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
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.
|
||||
|
||||
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.UseStaticFiles();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
RequestDelegate next,
|
||||
IOptions<DeveloperExceptionPageOptions> options,
|
||||
ILoggerFactory loggerFactory,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
DiagnosticSource diagnosticSource)
|
||||
{
|
||||
if (next == null)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace HealthChecksSample
|
|||
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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
|
|
@ -23,7 +23,7 @@ namespace HealthChecksSample
|
|||
.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
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -25,7 +25,7 @@ namespace HealthChecksSample
|
|||
.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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -18,7 +18,7 @@ namespace HealthChecksSample
|
|||
.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:
|
||||
// - at /health/ready for 'readiness'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -22,7 +22,7 @@ namespace HealthChecksSample
|
|||
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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
|
|
@ -44,7 +44,7 @@ namespace HostFilteringSample
|
|||
services.AddSingleton<IOptionsChangeTokenSource<HostFilteringOptions>>(new ConfigurationChangeTokenSource<HostFilteringOptions>(Config));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseHostFiltering();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -253,6 +253,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleOrigin", "CORS\sample
|
|||
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}"
|
||||
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
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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|x86.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -1501,6 +1575,11 @@ Global
|
|||
{52CDD110-77DD-4C4D-8C72-4570F6EF20DD} = {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}
|
||||
{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
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
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.
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, INodeServices nodeServices)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, INodeServices nodeServices)
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.NodeServices
|
||||
{
|
||||
|
|
@ -35,7 +36,7 @@ namespace Microsoft.AspNetCore.NodeServices
|
|||
InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds;
|
||||
WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone();
|
||||
|
||||
var hostEnv = serviceProvider.GetService<IHostingEnvironment>();
|
||||
var hostEnv = serviceProvider.GetService<IWebHostEnvironment>();
|
||||
if (hostEnv != null)
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
||||
var applicationLifetime = serviceProvider.GetService<IApplicationLifetime>();
|
||||
var applicationLifetime = serviceProvider.GetService<IHostApplicationLifetime>();
|
||||
if (applicationLifetime != null)
|
||||
{
|
||||
ApplicationStoppingToken = applicationLifetime.ApplicationStopping;
|
||||
|
|
@ -110,4 +111,4 @@ namespace Microsoft.AspNetCore.NodeServices
|
|||
/// </summary>
|
||||
public CancellationToken ApplicationStoppingToken { 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.
|
||||
|
||||
using System.IO;
|
||||
|
|
@ -13,12 +13,12 @@ namespace RewriteSample
|
|||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment environment)
|
||||
public Startup(IWebHostEnvironment environment)
|
||||
{
|
||||
Environment = environment;
|
||||
}
|
||||
|
||||
public IHostingEnvironment Environment { get; private set; }
|
||||
public IWebHostEnvironment Environment { get; private set; }
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
using System;
|
||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Rewrite
|
|||
/// <param name="options">The middleware options, containing the rules to apply.</param>
|
||||
public RewriteMiddleware(
|
||||
RequestDelegate next,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<RewriteOptions> options)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -13,22 +12,10 @@ namespace SessionSample
|
|||
{
|
||||
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)
|
||||
{
|
||||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.SpaServices;
|
|||
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
|
||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -61,9 +62,9 @@ namespace Microsoft.AspNetCore.Builder
|
|||
var applicationBuilder = spaBuilder.ApplicationBuilder;
|
||||
var serviceProvider = applicationBuilder.ApplicationServices;
|
||||
var nodeServices = GetNodeServices(serviceProvider);
|
||||
var applicationStoppingToken = serviceProvider.GetRequiredService<IApplicationLifetime>()
|
||||
var applicationStoppingToken = serviceProvider.GetRequiredService<IHostApplicationLifetime>()
|
||||
.ApplicationStopping;
|
||||
var applicationBasePath = serviceProvider.GetRequiredService<IHostingEnvironment>()
|
||||
var applicationBasePath = serviceProvider.GetRequiredService<IWebHostEnvironment>()
|
||||
.ContentRootPath;
|
||||
var moduleExport = new JavaScriptModuleExport(capturedBootModulePath);
|
||||
var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>())
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// 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.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SpaServices.Extensions.Proxy
|
|||
string pathPrefix,
|
||||
TimeSpan requestTimeout,
|
||||
Task<Uri> baseUriTask,
|
||||
IApplicationLifetime applicationLifetime)
|
||||
IHostApplicationLifetime applicationLifetime)
|
||||
{
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.SpaServices;
|
||||
using Microsoft.AspNetCore.SpaServices.Extensions.Proxy;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -85,8 +86,8 @@ namespace Microsoft.AspNetCore.Builder
|
|||
{
|
||||
var applicationLifetime = appBuilder
|
||||
.ApplicationServices
|
||||
.GetService(typeof(IApplicationLifetime));
|
||||
return ((IApplicationLifetime)applicationLifetime).ApplicationStopping;
|
||||
.GetService(typeof(IHostApplicationLifetime));
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices
|
||||
|
|
@ -45,7 +46,7 @@ namespace Microsoft.AspNetCore.SpaServices
|
|||
// Try to clarify the common scenario where someone runs an application in
|
||||
// Production environment without first publishing the whole application
|
||||
// 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())
|
||||
{
|
||||
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.
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.SpaServices.StaticFiles
|
|||
$"of {nameof(options)} cannot be null or empty.");
|
||||
}
|
||||
|
||||
var env = serviceProvider.GetRequiredService<IHostingEnvironment>();
|
||||
var env = serviceProvider.GetRequiredService<IWebHostEnvironment>();
|
||||
var absoluteRootPath = Path.Combine(
|
||||
env.ContentRootPath,
|
||||
options.RootPath);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.AspNetCore.NodeServices;
|
||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Webpack.ActionResults
|
||||
{
|
||||
|
|
@ -26,8 +27,8 @@ namespace Webpack.ActionResults
|
|||
public override async Task ExecuteResultAsync(ActionContext context)
|
||||
{
|
||||
var nodeServices = context.HttpContext.RequestServices.GetRequiredService<INodeServices>();
|
||||
var hostEnv = context.HttpContext.RequestServices.GetRequiredService<IHostingEnvironment>();
|
||||
var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService<IApplicationLifetime>();
|
||||
var hostEnv = context.HttpContext.RequestServices.GetRequiredService<IWebHostEnvironment>();
|
||||
var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService<IHostApplicationLifetime>();
|
||||
var applicationBasePath = hostEnv.ContentRootPath;
|
||||
var request = context.HttpContext.Request;
|
||||
var response = context.HttpContext.Response;
|
||||
|
|
@ -48,4 +49,4 @@ namespace Webpack.ActionResults
|
|||
await response.WriteAsync(prerenderedHtml.Html);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Webpack
|
|||
}
|
||||
|
||||
// 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
using System.Threading;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.NodeServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||
{
|
||||
|
|
@ -20,8 +21,8 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||
|
||||
public DefaultSpaPrerenderer(
|
||||
INodeServices nodeServices,
|
||||
IApplicationLifetime applicationLifetime,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IHostApplicationLifetime applicationLifetime,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_applicationBasePath = hostingEnvironment.ContentRootPath;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.NodeServices;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||
{
|
||||
|
|
@ -31,11 +32,11 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
|
||||
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;
|
||||
_applicationBasePath = hostEnv.ContentRootPath;
|
||||
|
||||
var applicationLifetime = (IApplicationLifetime)serviceProvider.GetService(typeof(IApplicationLifetime));
|
||||
var applicationLifetime = (IHostApplicationLifetime)serviceProvider.GetService(typeof(IHostApplicationLifetime));
|
||||
_applicationStoppingToken = applicationLifetime.ApplicationStopping;
|
||||
|
||||
// Consider removing the following. Having it means you can get away with not putting app.AddNodeServices()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace StaticFilesSample
|
|||
services.AddDirectoryBrowser();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment host)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment host)
|
||||
{
|
||||
Console.WriteLine("webroot: " + host.WebRootPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
/// Creates a new instance of the DefaultFilesMiddleware.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public DefaultFilesMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DefaultFilesOptions> options)
|
||||
public DefaultFilesMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DefaultFilesOptions> options)
|
||||
{
|
||||
if (next == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
/// Creates a new instance of the SendFileMiddleware. Using <see cref="HtmlEncoder.Default"/> instance.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
|
||||
public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
|
||||
: this(next, hostingEnv, HtmlEncoder.Default, options)
|
||||
{
|
||||
}
|
||||
|
|
@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
/// Creates a new instance of the SendFileMiddleware.
|
||||
/// </summary>
|
||||
/// <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="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)
|
||||
{
|
||||
|
|
@ -104,4 +104,4 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
return contents.Exists;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
{
|
||||
internal static class Helpers
|
||||
{
|
||||
internal static IFileProvider ResolveFileProvider(IHostingEnvironment hostingEnv)
|
||||
internal static IFileProvider ResolveFileProvider(IWebHostEnvironment hostingEnv)
|
||||
{
|
||||
if (hostingEnv.WebRootFileProvider == null) {
|
||||
throw new InvalidOperationException("Missing FileProvider.");
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
/// Creates a new instance of the StaticFileMiddleware.
|
||||
/// </summary>
|
||||
/// <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="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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
|
||||
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()) })
|
||||
{
|
||||
|
|
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
|||
|
||||
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()) })
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace AutobahnTestApp
|
|||
public class Startup
|
||||
{
|
||||
// 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// AuthType to sign out.
|
||||
var appEnv = HttpContext.RequestServices.GetService<IHostingEnvironment>();
|
||||
var appEnv = HttpContext.RequestServices.GetService<IWebHostEnvironment>();
|
||||
if (appEnv.EnvironmentName.StartsWith("OpenIdConnect"))
|
||||
{
|
||||
return new SignOutResult("OpenIdConnect", new AuthenticationProperties
|
||||
|
|
@ -509,4 +509,4 @@ namespace MusicStore.Controllers
|
|||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
|
@ -9,9 +9,9 @@ namespace MusicStore.Mocks.OpenIdConnect
|
|||
{
|
||||
internal class OpenIdConnectBackChannelHttpHandler : HttpMessageHandler
|
||||
{
|
||||
private IHostingEnvironment _env;
|
||||
private IWebHostEnvironment _env;
|
||||
|
||||
public OpenIdConnectBackChannelHttpHandler(IHostingEnvironment env)
|
||||
public OpenIdConnectBackChannelHttpHandler(IWebHostEnvironment env)
|
||||
{
|
||||
_env = env;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace MusicStore
|
|||
{
|
||||
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,
|
||||
//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 IHostingEnvironment Env { get; }
|
||||
public IWebHostEnvironment Env { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace MusicStore
|
|||
{
|
||||
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,
|
||||
//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>
|
||||
private static async Task CreateAdminUser(IServiceProvider serviceProvider)
|
||||
{
|
||||
var env = serviceProvider.GetService<IHostingEnvironment>();
|
||||
var env = serviceProvider.GetService<IWebHostEnvironment>();
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace MusicStore
|
|||
{
|
||||
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'
|
||||
// is found in both the registered sources, then the later source will win. By this way a Local config
|
||||
|
|
@ -220,4 +220,4 @@ namespace MusicStore
|
|||
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace MusicStore
|
|||
/// </summary>
|
||||
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'
|
||||
// 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;
|
||||
|
||||
public StartupOpenIdConnect(IHostingEnvironment hostingEnvironment)
|
||||
public StartupOpenIdConnect(IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
{
|
||||
manager = new ApplicationPartManager();
|
||||
|
||||
var environment = GetServiceFromCollection<IHostingEnvironment>(services);
|
||||
var environment = GetServiceFromCollection<IWebHostEnvironment>(services);
|
||||
var entryAssemblyName = environment?.ApplicationName;
|
||||
if (string.IsNullOrEmpty(entryAssemblyName))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
{
|
||||
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))
|
||||
{
|
||||
if (hostingEnvironment == null)
|
||||
|
|
|
|||
|
|
@ -152,9 +152,9 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
{
|
||||
// Arrange
|
||||
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();
|
||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
||||
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||
|
||||
// Act
|
||||
var builder = services.AddMvcCore();
|
||||
|
|
@ -173,12 +173,12 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
{
|
||||
// Arrange
|
||||
var services = new ServiceCollection();
|
||||
var environment = new Mock<IHostingEnvironment>(MockBehavior.Strict);
|
||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
||||
var environment = new Mock<IWebHostEnvironment>(MockBehavior.Strict);
|
||||
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();
|
||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
||||
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||
|
||||
// Act
|
||||
var builder = services.AddMvcCore();
|
||||
|
|
@ -196,11 +196,11 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
{
|
||||
// Arrange
|
||||
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 applicationName = assemblyName.FullName;
|
||||
environment.SetupGet(e => e.ApplicationName).Returns(applicationName).Verifiable();
|
||||
services.AddSingleton<IHostingEnvironment>(environment.Object);
|
||||
services.AddSingleton<IWebHostEnvironment>(environment.Object);
|
||||
|
||||
// Act
|
||||
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