diff --git a/samples/SampleApp/appsettings.json b/samples/SampleApp/appsettings.json index 2c651a7..66f0f7a 100644 --- a/samples/SampleApp/appsettings.json +++ b/samples/SampleApp/appsettings.json @@ -2,61 +2,47 @@ "Kestrel": { "EndPoints": { "Http": { - "Address": "127.0.0.1", - "Port": 5000 - }, + "Url": "http://localhost:5005" + } // To enable HTTPS using a certificate file, set the path to a .pfx file in // the "Path" property below and configure the password in user secrets. // The "Password" property should be set in user secrets. //"HttpsInlineCertFile": { - // "Address": "127.0.0.1", - // "Port": 5001, + // "Url": "http://localhost:5005" // "Certificate": { - // "Source": "File", - // "Path": "" + // "Path": "", + // "Password: "" // } //}, //"HttpsInlineCertStore": { - // "Address": "127.0.0.1", - // "Port": 5002, + // "Url": "http://localhost:5005" // "Certificate": { - // "Source": "Store", // "Subject": "", - // "StoreName": "", - // "StoreLocation": "", + // "Store": "", + // "Location": "", // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired) // } //}, - // To enable this endpoint, set the path to a .pfx file in the "Path" property - // of the "TestCert" certificate defined under the "Certificates" section. - // Configure the password in user secrets. - //"HttpsCertFile": { - // "Address": "127.0.0.1", - // "Port": 5003, - // "Certificate": "TestCert" + // This uses the cert defined under Certificates/Default or the development cert. + //"HttpsDefaultCert": { + // "Url": "http://localhost:5005" //} - - //"HttpsCertStore": { - // "Address": "127.0.0.1", - // "Port": 5004, - // "Certificate": "TestCertInStore" - //}, } }, "Certificates": { - //"TestCert": { - // "Source": "File", - // "Path": "" + //"Default": { + // "Path": "", + // "Password": "" //}, - //"TestCertInStore": { - // "Source": "Store", + // From cert store: + //"Default": { // "Subject": "", - // "StoreName": "", - // "StoreLocation": "", + // "Store": "", + // "Location": "", // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired certificates) //} } diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index df3b91d..1d5a1ec 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -115,7 +115,7 @@ private static IWebHost StartWith(string url, Action configu /// /// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, @@ -133,7 +133,7 @@ public static IWebHostBuilder CreateDefaultBuilder() => /// /// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, @@ -148,7 +148,10 @@ public static IWebHostBuilder CreateDefaultBuilder() => public static IWebHostBuilder CreateDefaultBuilder(string[] args) { var builder = new WebHostBuilder() - .UseKestrel() + .UseKestrel((builderContext, options) => + { + options.Configure(builderContext.Configuration.GetSection("Kestrel")); + }) .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureAppConfiguration((hostingContext, config) => { @@ -198,7 +201,7 @@ public static IWebHostBuilder CreateDefaultBuilder(string[] args) /// /// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index fa03852..3a9ac52 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -61,7 +61,8 @@ await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { // Assert server is Kestrel Assert.Equal("Kestrel", response.Headers.Server.ToString()); - + // Set from default config + Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri); // The application name will be sent in response when all asserts succeed in the test app. Assert.Equal(applicationName, responseText); } diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/test/TestSites/CreateDefaultBuilderApp/appsettings.json index bc5ff92..393b080 100644 --- a/test/TestSites/CreateDefaultBuilderApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderApp/appsettings.json @@ -1,3 +1,10 @@ { - "settingsKey": "settingsValue" + "settingsKey": "settingsValue", + "Kestrel": { + "Endpoints": { + "HTTP": { + "Url": "http://localhost:5002" + } + } + } }