asp net core 6.0 kestrel server is not working

Viewed 5474

I have this code running kestrel

builder.WebHost.UseKestrel().UseUrls("https://myfirstproj1.asp")
.UseIISIntegration();

but I can't access the site through the url I specified. What am I doing wrong?

2 Answers

.net 6 does not use UserUrls() method any more. This is how to do it on .net 6. On 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();

UseKestrel also works for me. No idea what the difference is :/

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseKestrel(serverOptions =>
{
    
    serverOptions.ListenAnyIP(4000);
    serverOptions.ListenAnyIP(4001, listenOptions => listenOptions.UseHttps());
});
Related