Print the application base path out

- This helps to show how the host is configured
This commit is contained in:
David Fowler 2016-01-24 23:54:04 -08:00 committed by John Luo
parent ae47bb21a6
commit 94593de0c1
1 changed files with 5 additions and 2 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Threading; using System.Threading;
using Microsoft.AspNetCore.Server.Features; using Microsoft.AspNetCore.Server.Features;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.PlatformAbstractions;
namespace Microsoft.AspNetCore.Hosting namespace Microsoft.AspNetCore.Hosting
{ {
@ -48,15 +49,17 @@ namespace Microsoft.AspNetCore.Hosting
var hostingEnvironment = host.Services.GetService<IHostingEnvironment>(); var hostingEnvironment = host.Services.GetService<IHostingEnvironment>();
var applicationLifetime = host.Services.GetService<IApplicationLifetime>(); var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
var applicationEnvironment = host.Services.GetService<IApplicationEnvironment>();
Console.WriteLine("Hosting environment: " + hostingEnvironment.EnvironmentName); Console.WriteLine($"Hosting environment: {hostingEnvironment.EnvironmentName}");
Console.WriteLine($"Application base path: {applicationEnvironment.ApplicationBasePath}");
var serverAddresses = host.ServerFeatures.Get<IServerAddressesFeature>()?.Addresses; var serverAddresses = host.ServerFeatures.Get<IServerAddressesFeature>()?.Addresses;
if (serverAddresses != null) if (serverAddresses != null)
{ {
foreach (var address in serverAddresses) foreach (var address in serverAddresses)
{ {
Console.WriteLine("Now listening on: " + address); Console.WriteLine($"Now listening on: {address}");
} }
} }