复制错误的步骤:
dotnet new webapi -o TodoApi
cd TodoApi
dotnet add package Microsoft.EntityFrameworkCore.InMemory
code -r ../TodoApi
dotnet dev-certs https --trust
Press yes on the pop-up
Press control+F5
Select .NET 5+ and .NET core
This auto generates launch.json and tasks.json
字符串
现在我按control+F5运行项目,它给出了下面的输出:
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Using launch settings from 'C:\Users\Archpo\Downloads\TodoApi\Properties\launchSettings.json' [Profile 'TodoApi']...
Unhandled exception. 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.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Microsoft.AspNetCore.Builder.WebApplication.Run(String url)
at Program.<Main>$(String[] args) in C:\Users\Archo\Downloads\TodoApi\Program.cs:line 25
型
我再次运行dotnet dev-certs https --trust
。然后按Control+F5 -与上面相同的错误。
2条答案
按热度按时间jm2pwxwz1#
运行
certmgr.msc
展开
Personal\Certificates
删除
Friendly Name
列值为ASP.NET Core HTTPS development certificate
的证书关闭窗口
运行
dotnet dev-certs https --trust
转到Visual Studio代码并按下Control+F5
未报告错误。
t3irkdon2#
未处理的异常。System.InvalidOperationException:无法配置HTTPS终结点。未指定服务器证书,并且找不到默认开发人员证书或默认开发人员证书已过期。若要生成开发人员证书,请运行“dotnet dev-certs https”。若要信任证书(仅限Windows和macOS),请运行“dotnet dev-certs https --trust”。
如果您正在使用dot Net Core程序编写,请转到launchsettings.json文件并在“applicationUrl”中删除https://localhost:7255:“https://localhost:5248”