Unable to start Kestrel - System.InvalidOperationException on Linux

Viewed 728

I have recently change of Operative System, From Ubuntu 20.04 to KDE Neon 5.21 .I installed .NET CORE 3.1.9 with Rider IDE.
So When I try to execute an asp.net core app, It trows the following Exception:

/home/toastedguy2/dotnet/dotnet /home/toastedguy2/Downloads/Food-Town/WebUI/bin/Debug/netcoreapp3.1/WebUI.dll
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.

It has never occurred to me on Windows or Ubuntu, so I'm not sure what's going on.
Here is the code of my program.cs class:

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}

Now here is the code of my Startup.cs file:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllersWithViews();
        services.AddDbContextPool<FoodTownDbContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("Standard")));
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
        });
    }
}

PD: It happends on every single asp.net core application.

1 Answers

It looks like i installed the dotnet core runtime instead of SDK, so that's why it's not working.

Related