为.net mvc core 启用 https
public static IHostBuilder CreateHostBuilder(string[] args) { var x509ca = new X509Certificate2("./ServerCert.pfx", "password"); return Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseKestrel(option => option.ConfigureEndpointDefaults(c=>c.UseHttps(x509ca))); webBuilder.UseStartup<Startup>(); }); }
appsetings.json内容:
{ "urls": "http://*:6000", "Serilog": { "MinimumLevel": { "Default": "Verbose", "Override": { "System": "Warning", "Microsoft": "Warning" } } } }