可以像在 IIS 下的 .Net 4.x 中一样在 Kestrel 和 .NET Core 中调试 HTTP 和 HTTPS

All*_*a_T 2 kestrel-http-server asp.net-core

我需要调试外部身份验证,它需要 HTTPS。同时对于大部分内部请求http就足够了。在 IIS 上托管我的 Web 应用程序时,侦听 80 和 443 端口没有问题,但是在我看来,Kesterl 托管了 ASP.NET Core,该端口严格绑定到 launchSettings.json 中的特定配置,例如:

"localCalls": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:40000"
    },
"externalIdentity": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:50000"
    }
Run Code Online (Sandbox Code Playgroud)

我很好奇,是否可以一次在两个端口上都有侦听器,而无需在其他配置中重新启动以更改协议。

小智 6

根据文档,您可以在同一配置中定义端点:

"localCalls": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development",
            "ASPNETCORE_URLS": "http://localhost:5000;https://localhost:5100"
      }
    }
Run Code Online (Sandbox Code Playgroud)