ASP.NET Coer Kestrel Web服务器配置终结点

Kestrel:已删除默认 HTTPS 绑定

从 .NET 7 的 Kestrel 中删除默认 HTTPS 地址和端口。 此变更是 dotnet/aspnetcore#42016 的一部分,这将改善处理 HTTPS 时的整体开发人员体验。

中断性变更:Kestrel:已删除默认 HTTPS 绑定 - .NET | Microsoft Learn

配置方式

为 ASP.NET Core Kestrel Web 服务器配置终结点 | Microsoft Learn

appsettings.json

"Kestrel": {
  "Endpoints": {
    "MyHttpEndpoint": {
      "Url": "http://localhost:5000"
    },
    "MyHttpsEndpoint": {
      "Url": "https://localhost:5001"
    }
  }
}

Program.cs

builder.WebHost.ConfigureKestrel((context, opt) =>
{
    opt.Listen(IPAddress.Loopback, 5000);
    opt.Listen(IPAddress.Loopback, 5001, listenOptions =>
    {
        listenOptions.UseHttps();
    });
});

你可能感兴趣的:(.NET,ASP.NET,Core,Kestrel,服务器,HTTPS)