168 references to WebHostDefaults
AutobahnTestApp (2)
Program.cs (2)
44
var urls = webHostBuilder.GetSetting(
WebHostDefaults
.ServerUrlsKey) ?? webHostBuilder.GetSetting("server.urls");
45
webHostBuilder.UseSetting(
WebHostDefaults
.ServerUrlsKey, string.Empty);
blazor-devserver (2)
Server\Program.cs (2)
36
[
WebHostDefaults
.EnvironmentKey] = "Development",
39
[
WebHostDefaults
.StaticWebAssetsKey] = name,
IIS.Tests (1)
Utilities\TestServer.cs (1)
151
.UseSetting(
WebHostDefaults
.ApplicationKey, typeof(TestServer).GetTypeInfo().Assembly.FullName)
InMemory.FunctionalTests (1)
TestTransport\TestServer.cs (1)
81
.UseSetting(
WebHostDefaults
.ShutdownTimeoutKey, context.ShutdownTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture))
Microsoft.AspNetCore (42)
ConfigureWebHostBuilder.cs (30)
40
var previousContentRootConfig = _configuration[
WebHostDefaults
.ContentRootKey];
42
var previousWebRootConfig = _configuration[
WebHostDefaults
.WebRootKey];
43
var previousApplication = _configuration[
WebHostDefaults
.ApplicationKey];
44
var previousEnvironment = _configuration[
WebHostDefaults
.EnvironmentKey];
45
var previousHostingStartupAssemblies = _configuration[
WebHostDefaults
.HostingStartupAssembliesKey];
46
var previousHostingStartupAssembliesExclude = _configuration[
WebHostDefaults
.HostingStartupExcludeAssembliesKey];
51
if (!string.Equals(previousWebRootConfig, _configuration[
WebHostDefaults
.WebRootKey], StringComparison.OrdinalIgnoreCase)
52
&& !string.Equals(HostingPathResolver.ResolvePath(previousWebRoot, previousContentRoot), HostingPathResolver.ResolvePath(_configuration[
WebHostDefaults
.WebRootKey], previousContentRoot), StringComparison.OrdinalIgnoreCase))
55
throw new NotSupportedException($"The web root changed from \"{HostingPathResolver.ResolvePath(previousWebRoot, previousContentRoot)}\" to \"{HostingPathResolver.ResolvePath(_configuration[
WebHostDefaults
.WebRootKey], previousContentRoot)}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
57
else if (!string.Equals(previousApplication, _configuration[
WebHostDefaults
.ApplicationKey], StringComparison.OrdinalIgnoreCase))
60
throw new NotSupportedException($"The application name changed from \"{previousApplication}\" to \"{_configuration[
WebHostDefaults
.ApplicationKey]}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
62
else if (!string.Equals(previousContentRootConfig, _configuration[
WebHostDefaults
.ContentRootKey], StringComparison.OrdinalIgnoreCase)
63
&& !string.Equals(previousContentRoot, HostingPathResolver.ResolvePath(_configuration[
WebHostDefaults
.ContentRootKey]), StringComparison.OrdinalIgnoreCase))
66
throw new NotSupportedException($"The content root changed from \"{previousContentRoot}\" to \"{HostingPathResolver.ResolvePath(_configuration[
WebHostDefaults
.ContentRootKey])}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
68
else if (!string.Equals(previousEnvironment, _configuration[
WebHostDefaults
.EnvironmentKey], StringComparison.OrdinalIgnoreCase))
71
throw new NotSupportedException($"The environment changed from \"{previousEnvironment}\" to \"{_configuration[
WebHostDefaults
.EnvironmentKey]}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
73
else if (!string.Equals(previousHostingStartupAssemblies, _configuration[
WebHostDefaults
.HostingStartupAssembliesKey], StringComparison.OrdinalIgnoreCase))
76
throw new NotSupportedException($"The hosting startup assemblies changed from \"{previousHostingStartupAssemblies}\" to \"{_configuration[
WebHostDefaults
.HostingStartupAssembliesKey]}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
78
else if (!string.Equals(previousHostingStartupAssembliesExclude, _configuration[
WebHostDefaults
.HostingStartupExcludeAssembliesKey], StringComparison.OrdinalIgnoreCase))
81
throw new NotSupportedException($"The hosting startup assemblies exclude list changed from \"{previousHostingStartupAssembliesExclude}\" to \"{_configuration[
WebHostDefaults
.HostingStartupExcludeAssembliesKey]}\". Changing the host configuration using WebApplicationBuilder.WebHost is not supported. Use WebApplication.CreateBuilder(WebApplicationOptions) instead.");
118
var previousApplication = _configuration[
WebHostDefaults
.ApplicationKey];
119
var previousEnvironment = _configuration[
WebHostDefaults
.EnvironmentKey];
120
var previousHostingStartupAssemblies = _configuration[
WebHostDefaults
.HostingStartupAssembliesKey];
121
var previousHostingStartupAssembliesExclude = _configuration[
WebHostDefaults
.HostingStartupExcludeAssembliesKey];
123
if (string.Equals(key,
WebHostDefaults
.WebRootKey, StringComparison.OrdinalIgnoreCase) &&
129
else if (string.Equals(key,
WebHostDefaults
.ApplicationKey, StringComparison.OrdinalIgnoreCase) &&
135
else if (string.Equals(key,
WebHostDefaults
.ContentRootKey, StringComparison.OrdinalIgnoreCase) &&
141
else if (string.Equals(key,
WebHostDefaults
.EnvironmentKey, StringComparison.OrdinalIgnoreCase) &&
147
else if (string.Equals(key,
WebHostDefaults
.HostingStartupAssembliesKey, StringComparison.OrdinalIgnoreCase) &&
153
else if (string.Equals(key,
WebHostDefaults
.HostingStartupExcludeAssembliesKey, StringComparison.OrdinalIgnoreCase) &&
WebApplicationBuilder.cs (10)
54
new KeyValuePair<string, string?>(
WebHostDefaults
.WebRootKey, options.WebRootPath),
117
new KeyValuePair<string, string?>(
WebHostDefaults
.WebRootKey, options.WebRootPath),
170
new KeyValuePair<string, string?>(
WebHostDefaults
.WebRootKey, options.WebRootPath),
221
webHostBuilder.UseSetting(
WebHostDefaults
.ApplicationKey, _hostApplicationBuilder.Environment.ApplicationName ?? "");
222
webHostBuilder.UseSetting(
WebHostDefaults
.PreventHostingStartupKey, Configuration[
WebHostDefaults
.PreventHostingStartupKey]);
223
webHostBuilder.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, Configuration[
WebHostDefaults
.HostingStartupAssembliesKey]);
224
webHostBuilder.UseSetting(
WebHostDefaults
.HostingStartupExcludeAssembliesKey, Configuration[
WebHostDefaults
.HostingStartupExcludeAssembliesKey]);
WebHost.cs (2)
107
builder.UseSetting(
WebHostDefaults
.ApplicationKey, applicationName);
159
if (string.IsNullOrEmpty(builder.GetSetting(
WebHostDefaults
.ContentRootKey)))
Microsoft.AspNetCore.Components.Endpoints (1)
DependencyInjection\DefaultRazorComponentsServiceOptionsConfiguration.cs (1)
24
var value = Configuration[
WebHostDefaults
.DetailedErrorsKey];
Microsoft.AspNetCore.Components.Server (1)
Circuits\CircuitOptionsJSInteropDetailedErrorsConfiguration.cs (1)
21
var value = Configuration[
WebHostDefaults
.DetailedErrorsKey];
Microsoft.AspNetCore.Hosting (36)
GenericHost\GenericWebHostBuilder.cs (4)
170
UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
193
UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
316
UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
339
UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
GenericHost\GenericWebHostService.cs (5)
71
var urls = Configuration[
WebHostDefaults
.ServerUrlsKey];
79
var httpPorts = Configuration[
WebHostDefaults
.HttpPortsKey] ?? string.Empty;
80
var httpsPorts = Configuration[
WebHostDefaults
.HttpsPortsKey] ?? string.Empty;
103
var preferHostingUrlsConfig = Configuration[
WebHostDefaults
.PreferHostingUrlsKey];
130
throw new InvalidOperationException($"No application configured. Please specify an application via IWebHostBuilder.UseStartup, IWebHostBuilder.Configure, or specifying the startup assembly via {nameof(
WebHostDefaults
.StartupAssemblyKey)} in the web host configuration.");
GenericHost\SlimWebHostBuilder.cs (1)
81
UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
Internal\WebHost.cs (3)
193
throw new InvalidOperationException($"No application configured. Please specify startup via IWebHostBuilder.UseStartup, IWebHostBuilder.Configure, injecting {nameof(IStartup)} or specifying the startup assembly via {nameof(
WebHostDefaults
.StartupAssemblyKey)} in the web host configuration.");
265
var urls = _config[
WebHostDefaults
.ServerUrlsKey] ?? _config[DeprecatedServerUrlsKey];
268
serverAddressesFeature!.PreferHostingUrls = WebHostUtilities.ParseBool(_config[
WebHostDefaults
.PreferHostingUrlsKey]);
Internal\WebHostOptions.cs (14)
20
ApplicationName = environment?.ApplicationName ?? GetConfig(
WebHostDefaults
.ApplicationKey) ?? Assembly.GetEntryAssembly()?.GetName().Name ?? string.Empty;
21
StartupAssembly = GetConfig(
WebHostDefaults
.StartupAssemblyKey);
22
DetailedErrors = WebHostUtilities.ParseBool(GetConfig(
WebHostDefaults
.DetailedErrorsKey));
23
CaptureStartupErrors = WebHostUtilities.ParseBool(GetConfig(
WebHostDefaults
.CaptureStartupErrorsKey));
24
Environment = environment?.EnvironmentName ?? GetConfig(
WebHostDefaults
.EnvironmentKey);
25
WebRoot = GetConfig(
WebHostDefaults
.WebRootKey);
26
ContentRootPath = environment?.ContentRootPath ?? GetConfig(
WebHostDefaults
.ContentRootKey);
27
PreventHostingStartup = WebHostUtilities.ParseBool(GetConfig(
WebHostDefaults
.PreventHostingStartupKey));
28
SuppressStatusMessages = WebHostUtilities.ParseBool(GetConfig(
WebHostDefaults
.SuppressStatusMessagesKey));
29
ServerUrls = GetConfig(
WebHostDefaults
.ServerUrlsKey);
30
PreferHostingUrls = WebHostUtilities.ParseBool(GetConfig(
WebHostDefaults
.PreferHostingUrlsKey));
33
HostingStartupAssemblies = Split(ApplicationName, GetConfig(
WebHostDefaults
.HostingStartupAssembliesKey));
34
HostingStartupExcludeAssemblies = Split(GetConfig(
WebHostDefaults
.HostingStartupExcludeAssembliesKey));
36
var timeout = GetConfig(
WebHostDefaults
.ShutdownTimeoutKey);
StaticWebAssets\StaticWebAssetsLoader.cs (1)
50
var candidate = configuration[
WebHostDefaults
.StaticWebAssetsKey] ?? ResolveRelativeToAssembly(environment);
WebHostBuilder.cs (4)
45
if (string.IsNullOrEmpty(GetSetting(
WebHostDefaults
.EnvironmentKey)))
48
UseSetting(
WebHostDefaults
.EnvironmentKey, Environment.GetEnvironmentVariable("Hosting:Environment")
52
if (string.IsNullOrEmpty(GetSetting(
WebHostDefaults
.ServerUrlsKey)))
55
UseSetting(
WebHostDefaults
.ServerUrlsKey, Environment.GetEnvironmentVariable("ASPNETCORE_SERVER.URLS"));
WebHostBuilderExtensions.cs (4)
43
hostBuilder.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
72
hostBuilder.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
102
hostBuilder.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
145
hostBuilder.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName);
Microsoft.AspNetCore.Hosting.Abstractions (10)
HostingAbstractionsWebHostBuilderExtensions.cs (10)
43
return hostBuilder.UseSetting(
WebHostDefaults
.CaptureStartupErrorsKey, captureStartupErrors ? "true" : "false");
58
.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName)
59
.UseSetting(
WebHostDefaults
.StartupAssemblyKey, startupAssemblyName);
90
return hostBuilder.UseSetting(
WebHostDefaults
.EnvironmentKey, environment);
103
return hostBuilder.UseSetting(
WebHostDefaults
.ContentRootKey, contentRoot);
116
return hostBuilder.UseSetting(
WebHostDefaults
.WebRootKey, webRoot);
129
return hostBuilder.UseSetting(
WebHostDefaults
.ServerUrlsKey, string.Join(';', urls));
141
return hostBuilder.UseSetting(
WebHostDefaults
.PreferHostingUrlsKey, preferHostingUrls ? "true" : "false");
152
return hostBuilder.UseSetting(
WebHostDefaults
.SuppressStatusMessagesKey, suppressStatusMessages ? "true" : "false");
163
return hostBuilder.UseSetting(
WebHostDefaults
.ShutdownTimeoutKey, ((int)timeout.TotalSeconds).ToString(CultureInfo.InvariantCulture));
Microsoft.AspNetCore.Hosting.Tests (32)
HostingEnvironmentExtensionsTests.cs (2)
21
[
WebHostDefaults
.WebRootKey] = "testroot"
68
[
WebHostDefaults
.EnvironmentKey] = "NewName"
WebHostBuilderTests.cs (20)
296
{
WebHostDefaults
.ApplicationKey, assemblyName },
297
{
WebHostDefaults
.HostingStartupAssembliesKey, assemblyName }
491
.UseSetting(
WebHostDefaults
.EnvironmentKey, "EnvA")
492
.UseSetting(
WebHostDefaults
.EnvironmentKey, "EnvB")
509
{
WebHostDefaults
.EnvironmentKey, "EnvB" }
517
.UseSetting(
WebHostDefaults
.EnvironmentKey, "EnvA")
535
{
WebHostDefaults
.EnvironmentKey, "EnvA" }
544
.UseSetting(
WebHostDefaults
.EnvironmentKey, "EnvB")
561
{
WebHostDefaults
.EnvironmentKey, "EnvA" }
570
{
WebHostDefaults
.EnvironmentKey, "EnvB" }
890
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName)
910
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, fullName + ";" + name)
927
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName)
947
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, typeof(WebHostBuilderTests).GetTypeInfo().Assembly.FullName)
948
.UseSetting(
WebHostDefaults
.ApplicationKey, startupAssemblyName)
1047
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName)
1048
.UseSetting(
WebHostDefaults
.HostingStartupExcludeAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName)
1165
.UseSetting(
WebHostDefaults
.PreventHostingStartupKey, "true")
1181
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, "SomeBogusName")
1202
.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, "SomeBogusName")
WebHostConfigurationsTests.cs (7)
16
{
WebHostDefaults
.WebRootKey, "wwwroot"},
17
{
WebHostDefaults
.ApplicationKey, "MyProjectReference"},
18
{
WebHostDefaults
.StartupAssemblyKey, "MyProjectReference" },
19
{
WebHostDefaults
.EnvironmentKey, Environments.Development},
20
{
WebHostDefaults
.DetailedErrorsKey, "true"},
21
{
WebHostDefaults
.CaptureStartupErrorsKey, "true" },
22
{
WebHostDefaults
.SuppressStatusMessagesKey, "true" }
WebHostTests.cs (3)
198
{
WebHostDefaults
.ShutdownTimeoutKey, "1" }
237
{
WebHostDefaults
.ShutdownTimeoutKey, "1" }
273
{
WebHostDefaults
.ShutdownTimeoutKey, "10" }
Microsoft.AspNetCore.Mvc.FunctionalTests (2)
SimpleWithWebApplicationBuilderTests.cs (2)
205
expectedWebRoot = Path.GetFullPath(Path.Combine(builder.GetSetting(
WebHostDefaults
.ContentRootKey), webRoot));
206
builder.UseSetting(
WebHostDefaults
.WebRootKey, webRoot);
Microsoft.AspNetCore.Server.IISIntegration (1)
WebHostBuilderIISExtensions.cs (1)
84
hostBuilder.UseSetting(
WebHostDefaults
.ServerUrlsKey, address);
Microsoft.AspNetCore.Server.IISIntegration.Tests (5)
IISMiddlewareTests.cs (5)
309
Assert.Null(webHostBuilder.GetSetting(
WebHostDefaults
.ServerUrlsKey));
310
Assert.Null(webHostBuilder.GetSetting(
WebHostDefaults
.PreferHostingUrlsKey));
322
Assert.Equal("http://127.0.0.1:12345", configuration[
WebHostDefaults
.ServerUrlsKey]);
323
Assert.Equal("true", configuration[
WebHostDefaults
.PreferHostingUrlsKey]);
350
Assert.Equal("http://127.0.0.1:12345", configuration[
WebHostDefaults
.ServerUrlsKey]);
Microsoft.AspNetCore.Server.Kestrel.Tests (2)
HttpsConfigurationTests.cs (2)
33
hostBuilder.UseSetting(
WebHostDefaults
.ServerUrlsKey, address);
67
hostBuilder.UseSetting(
WebHostDefaults
.ServerUrlsKey, $"{httpAddress};{httpsAddress}");
Microsoft.AspNetCore.Tests (24)
WebApplicationTests.cs (23)
393
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.ApplicationKey, nameof(WebApplicationTests)));
394
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.EnvironmentKey, envName));
395
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.ContentRootKey, contentRoot));
396
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.WebRootKey, webRoot));
397
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.HostingStartupAssembliesKey, "hosting"));
398
Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(
WebHostDefaults
.HostingStartupExcludeAssembliesKey, "hostingexclude"));
417
{
WebHostDefaults
.ApplicationKey, nameof(WebApplicationTests) }
425
{
WebHostDefaults
.EnvironmentKey, envName }
433
{
WebHostDefaults
.ContentRootKey, contentRoot }
441
{
WebHostDefaults
.WebRootKey, webRoot }
449
{
WebHostDefaults
.HostingStartupAssembliesKey, "hosting" }
457
{
WebHostDefaults
.HostingStartupExcludeAssembliesKey, "hostingexclude" }
840
$"--{
WebHostDefaults
.ApplicationKey}=testhost",
841
$"--{
WebHostDefaults
.ContentRootKey}={contentRoot}",
842
$"--{
WebHostDefaults
.WebRootKey}=wwwroot2",
843
$"--{
WebHostDefaults
.EnvironmentKey}=Test"
890
$"--{
WebHostDefaults
.ApplicationKey}={nameof(WebApplicationTests)}",
891
$"--{
WebHostDefaults
.ContentRootKey}={contentRoot}",
892
$"--{
WebHostDefaults
.EnvironmentKey}={envName}",
893
$"--{
WebHostDefaults
.WebRootKey}={webRoot}",
2250
builder.Configuration[
WebHostDefaults
.ApplicationKey] = nameof(WebApplicationTests);
2251
builder.Configuration[
WebHostDefaults
.EnvironmentKey] = envName;
2252
builder.Configuration[
WebHostDefaults
.ContentRootKey] = contentRoot;
WebHostTests.cs (1)
26
Assert.Equal("http://localhost:5001", builder.GetSetting(
WebHostDefaults
.ServerUrlsKey));
SignalRSamples (1)
Program.cs (1)
23
.UseSetting(
WebHostDefaults
.PreventHostingStartupKey, "true")
SocialWeather (1)
Program.cs (1)
14
.UseSetting(
WebHostDefaults
.PreventHostingStartupKey, "true")
Sockets.BindTests (2)
src\Servers\Kestrel\shared\test\TransportTestHelpers\TestServer.cs (2)
106
.UseSetting(
WebHostDefaults
.ApplicationKey, typeof(TestServer).Assembly.FullName)
107
.UseSetting(
WebHostDefaults
.ShutdownTimeoutKey, TestConstants.DefaultTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture))
Sockets.FunctionalTests (2)
src\Servers\Kestrel\shared\test\TransportTestHelpers\TestServer.cs (2)
106
.UseSetting(
WebHostDefaults
.ApplicationKey, typeof(TestServer).Assembly.FullName)
107
.UseSetting(
WebHostDefaults
.ShutdownTimeoutKey, TestConstants.DefaultTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture))