asp net core 6.0 kestrel服务器不工作

раг*_*гня 7 c# asp.net kestrel-http-server .net-6.0

我有这个代码运行 kestrel

builder.WebHost.UseKestrel().UseUrls("https://myfirstproj1.asp")
.UseIISIntegration();
Run Code Online (Sandbox Code Playgroud)

但我无法通过我指定的网址访问该网站。我究竟做错了什么?

小智 27

.net 6 不再使用 UserUrls() 方法。这是在 .net 6 上执行此操作的方法。 在 Program.cs 上

var builder = WebApplication.CreateBuilder(args);

//...
builder.WebHost.ConfigureKestrel(options =>
{
    options.ListenAnyIP(5001); // to listen for incoming http connection on port 5001
    options.ListenAnyIP(7001, configure => configure.UseHttps()); // to listen for incoming https connection on port 7001
});
//...
var app = builder.Build();
Run Code Online (Sandbox Code Playgroud)