我创建netcore3.1webapi程序,本地发布后打开exe文件然后用apipost或者浏览器是可以访问具体接口的,但是在别人电脑无法运行,或者直接报错。
无
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 fo
und or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the c
ertificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
inkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenO
ptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenO
ptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesS
trategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(
IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger l
ogger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext
](IHttpApplication`1 application, CancellationToken cancellationToken)
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS
endpoint. No server certificate was specified, and the default developer certif
icate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the c
ertificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
inkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenO
ptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenO
ptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesS
trategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(
IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger l
ogger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext
](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(Cancellation
Token cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken ca
ncellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IH
ost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IH
ost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost h
ost)
at V2XPCT.API.Program.Main(String[] args) in D:\liuhuairiWorkSpace\v2x\branch
es\V2XPCT\V2XPCT.API\Program.cs:line 27
我以为是因为没有安装netcore运行环境,3.1运行时以及sdk都尝试过,但是并没解决问题。现在不确定是什么原因引起的;
报错信息说是kestrel没启动我已经在Startup或者program中启用了
public void ConfigureServices(IServiceCollection services)
{
services.Configure<KestrelServerOptions>(
Configuration.GetSection("Kestrel"));
}
/// <summary>
/// 构建IHostBuilder
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.Configure<KestrelServerOptions>(
context.Configuration.GetSection("Kestrel"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseUrls("http://*:5000;https://*:5001");
});
at V2XPCT.API.Program.Main(String[] args) in D:\liuhuairiWorkSpace\v2x\branch
es\V2XPCT\V2XPCT.API\Program.cs:line 27 这一行报错信息在我电脑上没有,这是我在测试电脑上发现的。