168 references to WebHostDefaults
AutobahnTestApp (2)
Program.cs (2)
44var urls = webHostBuilder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? webHostBuilder.GetSetting("server.urls"); 45webHostBuilder.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)
42var previousContentRootConfig = _configuration[WebHostDefaults.ContentRootKey]; 44var previousWebRootConfig = _configuration[WebHostDefaults.WebRootKey]; 45var previousApplication = _configuration[WebHostDefaults.ApplicationKey]; 46var previousEnvironment = _configuration[WebHostDefaults.EnvironmentKey]; 47var previousHostingStartupAssemblies = _configuration[WebHostDefaults.HostingStartupAssembliesKey]; 48var previousHostingStartupAssembliesExclude = _configuration[WebHostDefaults.HostingStartupExcludeAssembliesKey]; 53if (!string.Equals(previousWebRootConfig, _configuration[WebHostDefaults.WebRootKey], StringComparison.OrdinalIgnoreCase) 54&& !string.Equals(HostingPathResolver.ResolvePath(previousWebRoot, previousContentRoot), HostingPathResolver.ResolvePath(_configuration[WebHostDefaults.WebRootKey], previousContentRoot), StringComparison.OrdinalIgnoreCase)) 57throw 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."); 59else if (!string.Equals(previousApplication, _configuration[WebHostDefaults.ApplicationKey], StringComparison.OrdinalIgnoreCase)) 62throw 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."); 64else if (!string.Equals(previousContentRootConfig, _configuration[WebHostDefaults.ContentRootKey], StringComparison.OrdinalIgnoreCase) 65&& !string.Equals(previousContentRoot, HostingPathResolver.ResolvePath(_configuration[WebHostDefaults.ContentRootKey]), StringComparison.OrdinalIgnoreCase)) 68throw 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."); 70else if (!string.Equals(previousEnvironment, _configuration[WebHostDefaults.EnvironmentKey], StringComparison.OrdinalIgnoreCase)) 73throw 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."); 75else if (!string.Equals(previousHostingStartupAssemblies, _configuration[WebHostDefaults.HostingStartupAssembliesKey], StringComparison.OrdinalIgnoreCase)) 78throw 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."); 80else if (!string.Equals(previousHostingStartupAssembliesExclude, _configuration[WebHostDefaults.HostingStartupExcludeAssembliesKey], StringComparison.OrdinalIgnoreCase)) 83throw 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."); 120var previousApplication = _configuration[WebHostDefaults.ApplicationKey]; 121var previousEnvironment = _configuration[WebHostDefaults.EnvironmentKey]; 122var previousHostingStartupAssemblies = _configuration[WebHostDefaults.HostingStartupAssembliesKey]; 123var previousHostingStartupAssembliesExclude = _configuration[WebHostDefaults.HostingStartupExcludeAssembliesKey]; 125if (string.Equals(key, WebHostDefaults.WebRootKey, StringComparison.OrdinalIgnoreCase) && 131else if (string.Equals(key, WebHostDefaults.ApplicationKey, StringComparison.OrdinalIgnoreCase) && 137else if (string.Equals(key, WebHostDefaults.ContentRootKey, StringComparison.OrdinalIgnoreCase) && 143else if (string.Equals(key, WebHostDefaults.EnvironmentKey, StringComparison.OrdinalIgnoreCase) && 149else if (string.Equals(key, WebHostDefaults.HostingStartupAssembliesKey, StringComparison.OrdinalIgnoreCase) && 155else if (string.Equals(key, WebHostDefaults.HostingStartupExcludeAssembliesKey, StringComparison.OrdinalIgnoreCase) &&
WebApplicationBuilder.cs (10)
54new KeyValuePair<string, string?>(WebHostDefaults.WebRootKey, options.WebRootPath), 117new KeyValuePair<string, string?>(WebHostDefaults.WebRootKey, options.WebRootPath), 172new KeyValuePair<string, string?>(WebHostDefaults.WebRootKey, options.WebRootPath), 223webHostBuilder.UseSetting(WebHostDefaults.ApplicationKey, _hostApplicationBuilder.Environment.ApplicationName ?? ""); 224webHostBuilder.UseSetting(WebHostDefaults.PreventHostingStartupKey, Configuration[WebHostDefaults.PreventHostingStartupKey]); 225webHostBuilder.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, Configuration[WebHostDefaults.HostingStartupAssembliesKey]); 226webHostBuilder.UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, Configuration[WebHostDefaults.HostingStartupExcludeAssembliesKey]);
WebHost.cs (2)
108builder.UseSetting(WebHostDefaults.ApplicationKey, applicationName); 162if (string.IsNullOrEmpty(builder.GetSetting(WebHostDefaults.ContentRootKey)))
Microsoft.AspNetCore.Components.Endpoints (1)
DependencyInjection\DefaultRazorComponentsServiceOptionsConfiguration.cs (1)
24var value = Configuration[WebHostDefaults.DetailedErrorsKey];
Microsoft.AspNetCore.Components.Server (1)
Circuits\CircuitOptionsJSInteropDetailedErrorsConfiguration.cs (1)
21var value = Configuration[WebHostDefaults.DetailedErrorsKey];
Microsoft.AspNetCore.Hosting (36)
GenericHost\GenericWebHostBuilder.cs (4)
170UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 195UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 320UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 345UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName);
GenericHost\GenericWebHostService.cs (5)
71var urls = Configuration[WebHostDefaults.ServerUrlsKey]; 79var httpPorts = Configuration[WebHostDefaults.HttpPortsKey] ?? string.Empty; 80var httpsPorts = Configuration[WebHostDefaults.HttpsPortsKey] ?? string.Empty; 103var preferHostingUrlsConfig = Configuration[WebHostDefaults.PreferHostingUrlsKey]; 130throw 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)
81UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName);
Internal\WebHost.cs (3)
194throw 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."); 266var urls = _config[WebHostDefaults.ServerUrlsKey] ?? _config[DeprecatedServerUrlsKey]; 269serverAddressesFeature!.PreferHostingUrls = WebHostUtilities.ParseBool(_config[WebHostDefaults.PreferHostingUrlsKey]);
Internal\WebHostOptions.cs (14)
20ApplicationName = environment?.ApplicationName ?? GetConfig(WebHostDefaults.ApplicationKey) ?? Assembly.GetEntryAssembly()?.GetName().Name ?? string.Empty; 21StartupAssembly = GetConfig(WebHostDefaults.StartupAssemblyKey); 22DetailedErrors = WebHostUtilities.ParseBool(GetConfig(WebHostDefaults.DetailedErrorsKey)); 23CaptureStartupErrors = WebHostUtilities.ParseBool(GetConfig(WebHostDefaults.CaptureStartupErrorsKey)); 24Environment = environment?.EnvironmentName ?? GetConfig(WebHostDefaults.EnvironmentKey); 25WebRoot = GetConfig(WebHostDefaults.WebRootKey); 26ContentRootPath = environment?.ContentRootPath ?? GetConfig(WebHostDefaults.ContentRootKey); 27PreventHostingStartup = WebHostUtilities.ParseBool(GetConfig(WebHostDefaults.PreventHostingStartupKey)); 28SuppressStatusMessages = WebHostUtilities.ParseBool(GetConfig(WebHostDefaults.SuppressStatusMessagesKey)); 29ServerUrls = GetConfig(WebHostDefaults.ServerUrlsKey); 30PreferHostingUrls = WebHostUtilities.ParseBool(GetConfig(WebHostDefaults.PreferHostingUrlsKey)); 33HostingStartupAssemblies = Split(ApplicationName, GetConfig(WebHostDefaults.HostingStartupAssembliesKey)); 34HostingStartupExcludeAssemblies = Split(GetConfig(WebHostDefaults.HostingStartupExcludeAssembliesKey)); 36var timeout = GetConfig(WebHostDefaults.ShutdownTimeoutKey);
StaticWebAssets\StaticWebAssetsLoader.cs (1)
50var candidate = configuration[WebHostDefaults.StaticWebAssetsKey] ?? ResolveRelativeToAssembly(environment);
WebHostBuilder.cs (4)
46if (string.IsNullOrEmpty(GetSetting(WebHostDefaults.EnvironmentKey))) 49UseSetting(WebHostDefaults.EnvironmentKey, Environment.GetEnvironmentVariable("Hosting:Environment") 53if (string.IsNullOrEmpty(GetSetting(WebHostDefaults.ServerUrlsKey))) 56UseSetting(WebHostDefaults.ServerUrlsKey, Environment.GetEnvironmentVariable("ASPNETCORE_SERVER.URLS"));
WebHostBuilderExtensions.cs (4)
43hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 72hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 102hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName); 145hostBuilder.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName);
Microsoft.AspNetCore.Hosting.Abstractions (10)
HostingAbstractionsWebHostBuilderExtensions.cs (10)
43return hostBuilder.UseSetting(WebHostDefaults.CaptureStartupErrorsKey, captureStartupErrors ? "true" : "false"); 58.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName) 59.UseSetting(WebHostDefaults.StartupAssemblyKey, startupAssemblyName); 90return hostBuilder.UseSetting(WebHostDefaults.EnvironmentKey, environment); 103return hostBuilder.UseSetting(WebHostDefaults.ContentRootKey, contentRoot); 116return hostBuilder.UseSetting(WebHostDefaults.WebRootKey, webRoot); 129return hostBuilder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Join(';', urls)); 141return hostBuilder.UseSetting(WebHostDefaults.PreferHostingUrlsKey, preferHostingUrls ? "true" : "false"); 152return hostBuilder.UseSetting(WebHostDefaults.SuppressStatusMessagesKey, suppressStatusMessages ? "true" : "false"); 163return 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)
298{ WebHostDefaults.ApplicationKey, assemblyName }, 299{ WebHostDefaults.HostingStartupAssembliesKey, assemblyName } 495.UseSetting(WebHostDefaults.EnvironmentKey, "EnvA") 496.UseSetting(WebHostDefaults.EnvironmentKey, "EnvB") 513{ WebHostDefaults.EnvironmentKey, "EnvB" } 521.UseSetting(WebHostDefaults.EnvironmentKey, "EnvA") 539{ WebHostDefaults.EnvironmentKey, "EnvA" } 548.UseSetting(WebHostDefaults.EnvironmentKey, "EnvB") 565{ WebHostDefaults.EnvironmentKey, "EnvA" } 574{ WebHostDefaults.EnvironmentKey, "EnvB" } 894.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName) 914.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, fullName + ";" + name) 931.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName) 951.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, typeof(WebHostBuilderTests).GetTypeInfo().Assembly.FullName) 952.UseSetting(WebHostDefaults.ApplicationKey, startupAssemblyName) 1051.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName) 1052.UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, typeof(TestStartupAssembly1.TestHostingStartup1).GetTypeInfo().Assembly.FullName) 1169.UseSetting(WebHostDefaults.PreventHostingStartupKey, "true") 1185.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "SomeBogusName") 1206.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)
200{ WebHostDefaults.ShutdownTimeoutKey, "1" } 239{ WebHostDefaults.ShutdownTimeoutKey, "1" } 275{ WebHostDefaults.ShutdownTimeoutKey, "10" }
Microsoft.AspNetCore.Mvc.FunctionalTests (2)
SimpleWithWebApplicationBuilderTests.cs (2)
205expectedWebRoot = Path.GetFullPath(Path.Combine(builder.GetSetting(WebHostDefaults.ContentRootKey), webRoot)); 206builder.UseSetting(WebHostDefaults.WebRootKey, webRoot);
Microsoft.AspNetCore.Server.IISIntegration (1)
WebHostBuilderIISExtensions.cs (1)
84hostBuilder.UseSetting(WebHostDefaults.ServerUrlsKey, address);
Microsoft.AspNetCore.Server.IISIntegration.Tests (5)
IISMiddlewareTests.cs (5)
308Assert.Null(webHostBuilder.GetSetting(WebHostDefaults.ServerUrlsKey)); 309Assert.Null(webHostBuilder.GetSetting(WebHostDefaults.PreferHostingUrlsKey)); 321Assert.Equal("http://127.0.0.1:12345", configuration[WebHostDefaults.ServerUrlsKey]); 322Assert.Equal("true", configuration[WebHostDefaults.PreferHostingUrlsKey]); 349Assert.Equal("http://127.0.0.1:12345", configuration[WebHostDefaults.ServerUrlsKey]);
Microsoft.AspNetCore.Server.Kestrel.Tests (2)
HttpsConfigurationTests.cs (2)
37.UseSetting(WebHostDefaults.ServerUrlsKey, address); 75.UseSetting(WebHostDefaults.ServerUrlsKey, $"{httpAddress};{httpsAddress}");
Microsoft.AspNetCore.Tests (24)
WebApplicationTests.cs (23)
395Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ApplicationKey, nameof(WebApplicationTests))); 396Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.EnvironmentKey, envName)); 397Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ContentRootKey, contentRoot)); 398Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.WebRootKey, webRoot)); 399Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "hosting")); 400Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, "hostingexclude")); 419{ WebHostDefaults.ApplicationKey, nameof(WebApplicationTests) } 427{ WebHostDefaults.EnvironmentKey, envName } 435{ WebHostDefaults.ContentRootKey, contentRoot } 443{ WebHostDefaults.WebRootKey, webRoot } 451{ WebHostDefaults.HostingStartupAssembliesKey, "hosting" } 459{ WebHostDefaults.HostingStartupExcludeAssembliesKey, "hostingexclude" } 842$"--{WebHostDefaults.ApplicationKey}=testhost", 843$"--{WebHostDefaults.ContentRootKey}={contentRoot}", 844$"--{WebHostDefaults.WebRootKey}=wwwroot2", 845$"--{WebHostDefaults.EnvironmentKey}=Test" 892$"--{WebHostDefaults.ApplicationKey}={nameof(WebApplicationTests)}", 893$"--{WebHostDefaults.ContentRootKey}={contentRoot}", 894$"--{WebHostDefaults.EnvironmentKey}={envName}", 895$"--{WebHostDefaults.WebRootKey}={webRoot}", 2252builder.Configuration[WebHostDefaults.ApplicationKey] = nameof(WebApplicationTests); 2253builder.Configuration[WebHostDefaults.EnvironmentKey] = envName; 2254builder.Configuration[WebHostDefaults.ContentRootKey] = contentRoot;
WebHostTests.cs (1)
28Assert.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)
103.UseSetting(WebHostDefaults.ApplicationKey, typeof(TestServer).Assembly.FullName) 104.UseSetting(WebHostDefaults.ShutdownTimeoutKey, TestConstants.DefaultTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture))
Sockets.FunctionalTests (2)
src\Servers\Kestrel\shared\test\TransportTestHelpers\TestServer.cs (2)
103.UseSetting(WebHostDefaults.ApplicationKey, typeof(TestServer).Assembly.FullName) 104.UseSetting(WebHostDefaults.ShutdownTimeoutKey, TestConstants.DefaultTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture))