Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

463
Views
Using Kestrel https .net core 6

I've got app in .net core 5. And this is the code in Startup.cs

'''''

public static IHostBuilder CreateHostBuilder(string[] args) =>
        //Host.CreateDefaultBuilder(args)
        //    .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
    
        Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder => {
        webBuilder
            .UseStartup<Startup>()
            .UseKestrel(o =>
            {
                o.Listen(IPAddress.Any, 443, opt =>
                {
                    opt.UseHttps("pathfto.pfx", "passwordtocert");
                });
            });
    });

I would like to take upgrade it to .net core 6

I thought that it would be like this

var builder = WebApplication.CreateBuilder(args);

builder.Host
.ConfigureWebHostDefaults(webBuilder =>
{
    webBuilder
        .UseKestrel(o =>
        {
            o.Listen(IPAddress.Any, 443, opt => { opt.UseHttps("pathto.pfx", "passwordtocert"); });
        });
});

But it doesn't work when I try compile it.

Thank you in advance for any solutions.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try to use builder.WebHost

builder.WebHost.ConfigureKestrel(options =>
{
    options.Listen(IPAddress.Any, int.Parse(builder.Configuration.GetSection("SSL")["port"]), listenOptions =>
    {
        listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
        if (builder.Configuration.GetSection("SSL")["sertificateName"].Trim() != "")
            listenOptions.UseHttps(Path.Combine(AppContext.BaseDirectory, "cfg", builder.Configuration.GetSection("SSL")["sertificateName"]), builder.Configuration.GetSection("SSL")["password"]);

    });
});

More details you find on https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!