提问人:variable 提问时间:3/25/2022 最后编辑:variable 更新时间:11/18/2023 访问量:7910
未处理的异常。System.InvalidOperationException:无法配置 HTTPS 终结点(与代码)
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint (vs code)
问:
复制错误的步骤:
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
我又跑了.然后按 Ctrl+F5 - 与上述错误相同。dotnet dev-certs https --trust
答:
7赞
variable
3/26/2022
#1
跑certmgr.msc
扩大Personal\Certificates
删除列值为Friendly Name
ASP.NET Core HTTPS development certificate
关闭窗口
跑dotnet dev-certs https --trust
转到 Visual Studio Code 并按 Ctrl+F5
未报告错误。
0赞
Afshin Estarabadi
11/18/2023
#2
未处理的异常。System.InvalidOperationException:无法配置 HTTPS 终结点。未指定服务器证书,并且找不到默认开发人员证书或已过期。若要生成开发人员证书,请运行“dotnet dev-certs https”。若要信任证书(仅限 Windows 和 macOS),请运行“dotnet dev-certs https --trust”。
如果您使用 dot Net Core 程序编写,请转到 launchsettings.json 文件并 https://localhost:7255 删除 “applicationUrl”: “https://localhost:7255;http://localhost:5248”
评论
0赞
Afshin Estarabadi
11/25/2023
或使用 iis Express 运行项目
评论