Add kestrel config to CreateDefaultBuilder
This commit is contained in:
parent
ee9b080875
commit
7511a4da7f
|
|
@ -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 to .pfx file>"
|
||||
// "Path": "<path to .pfx file>",
|
||||
// "Password: "<cert 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": "<file>",
|
||||
// "Password": "<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)
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||
/// use Kestrel as the web server,
|
||||
/// 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,
|
||||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||
/// use Kestrel as the web server,
|
||||
/// 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,
|
||||
|
|
@ -148,7 +148,10 @@ namespace Microsoft.AspNetCore
|
|||
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 @@ namespace Microsoft.AspNetCore
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
|
||||
/// use Kestrel as the web server,
|
||||
/// 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,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ namespace Microsoft.AspNetCore.Tests
|
|||
{
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
{
|
||||
"settingsKey": "settingsValue"
|
||||
"settingsKey": "settingsValue",
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"HTTP": {
|
||||
"Url": "http://localhost:5002"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue