相关疑难解决方法(0)

在ASP.NET Core中的Program.Main中访问环境名称

使用ASP.NET Mvc Core我需要将我的开发环境设置为使用https,因此我将以下内容添加到MainProgram.cs中的方法:

var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseKestrel(cfg => cfg.UseHttps("ssl-dev.pfx", "Password"))
                .UseUrls("https://localhost:5000")
                .UseApplicationInsights()
                .Build();
                host.Run();
Run Code Online (Sandbox Code Playgroud)

如何在此处访问托管环境,以便我可以有条件地设置协议/端口号/证书?

理想情况下,我会使用CLI来操纵我的托管环境,如下所示:

dotnet run --server.urls https://localhost:5000 --cert ssl-dev.pfx password
Run Code Online (Sandbox Code Playgroud)

但似乎没有办法从命令行使用证书.

c# kestrel asp.net-core

51
推荐指数
3
解决办法
2万
查看次数

标签 统计

asp.net-core ×1

c# ×1

kestrel ×1