问题描述
我最近对操作系统进行了更改,从Ubuntu 20.04到KDE Neon 5.21。我使用Rider IDE安装了.NET CORE 3.1.9。
因此,当我尝试执行asp.net核心应用程序时,它抛出以下异常:
/ home / toastedguy2 / dotnet / dotnet /home/toastedguy2/Downloads/Food-Town/WebUI/bin/Debug/netcoreapp3.1/WebUI.dll
暴击: Microsoft.AspNetCore.Server.Kestrel [0]
无法启动Kestrel。
system.invalidOperationException:无法配置HTTPS端点。未指定服务器证书,并且找不到默认的开发者证书或该证书已过期。要生成开发者证书,请运行“ dotnet dev-certs https”。要信任证书(仅限Windows和macOS),请运行'dotnet dev-certs https --trust'。 有关配置HTTPS的更多信息,请参见https://go.microsoft.com/fwlink/?linkid=848054。
在Windows或Ubuntu上,这从未发生过,因此我不确定发生了什么。
这是我的 program.cs 类的代码:
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>(); });
}
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:它发生在每个单独的asp.net核心应用程序中。
解决方法
好像我安装了dotnet core运行时而不是SDK,所以这就是为什么它不起作用。