目的
次のようなエラーが出た時になんとかする
System.InvalidOperationException: HTTPS endpoints can only be configured using KestrelServerOptions.Listen().
方法
UseUrls
でhttpのURLを指定する
サンプルコード
return WebHost.CreateDefaultBuilder(args) .UseUrls("http://localhost:5000") .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .UseApplicationInsights() .Build();
参考リンク
Kestrel web server implementation in ASP.NET Core | Microsoft Docs