C# 如何修复';无法配置HTTPS终结点。未指定服务器证书,无法找到默认的开发人员证书;

C# 如何修复';无法配置HTTPS终结点。未指定服务器证书,无法找到默认的开发人员证书;,c#,asp.net-mvc,windows,ssl,ssl-certificate,C#,Asp.net Mvc,Windows,Ssl,Ssl Certificate,我能够毫无问题地运行我编写的控制台web应用程序,并获得所需的输出,该输出将消息显示回命令提示符 然而,我现在已经将这个web应用程序引用到了一个控制台应用程序中,我现在得到了标题中描述的错误 我已尝试在“证书-当前用户”和“证书-受信任的根证书颁发机构”中手动删除MMC中的localhost证书。我还尝试进入visual studio命令提示符并执行dotnet dev certs https--clean然后执行dotnet dev certs https``以及dotnet dev cer

我能够毫无问题地运行我编写的控制台web应用程序,并获得所需的输出,该输出将消息显示回命令提示符

然而,我现在已经将这个web应用程序引用到了一个控制台应用程序中,我现在得到了标题中描述的错误

我已尝试在“证书-当前用户”和“证书-受信任的根证书颁发机构”中手动删除MMC中的
localhost
证书。我还尝试进入visual studio命令提示符并执行
dotnet dev certs https--clean
然后执行
dotnet dev certs https``以及
dotnet dev certs https--trust``我也使用
verbose
执行,这并没有改变结果

我还修复了IIS 10.0 Express并重新启动了笔记本电脑,以便获得
IIS Express开发证书

控制台应用程序C#(Program.cs):

Web应用程序C#(Program.cs):

只是重申一下,没有控制台应用程序或将web应用程序设置为启动应用程序运行良好,通常我会包括预期结果,但这只是控制台应用程序中的大量文本

我假设问题与证书有关,或者可能存在冲突,我没有看到

编辑:我还应该提到我在Windows10上。当我执行``dotnet dev certs https--检查``时,我得到消息“找到了一个有效的证书。”

namespace Rapiscan264_3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] argsWeb = new string[] { "192.168.2.2", "1234" };
            WebApplication1.Program.Main(argsWeb);
            ;
        }
    }
}
namespace WebApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine($"HALO REST Server Simulator Copyright 2019\n");

            IPAddress ipAddress = IPAddress.Parse("192.168.2.2");
            int port = 1234;

            if (args.Length < 2)
            {
                Console.WriteLine($"*ERROR* - Number of Arguments Passed to Startup Incorrect, Expected 2 but Received { args.Length }!\n");
            }
            else
            {
                if (!IPAddress.TryParse(args[0], out ipAddress))
                {
                    Console.WriteLine($"*ERROR* - Invalid IP Address Configured, IP={ args[0] }\n");
                }

                if (!int.TryParse(args[1], out port))
                {
                    Console.WriteLine($"*ERROR* - Invalid Port Configured, Port={ args[1] }\n");
                }
            }


            string url = $"https://{ ipAddress.ToString() }:{ port.ToString() }";
            Console.WriteLine($"Starting REST Server with URL = { url }\n");
             CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
                .UseUrls("https://192.168.2.2:1234")
                .UseStartup<Startup>();
    }
}
namespace WebApplication1
{
    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.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);           
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            env.EnvironmentName = "Development";
            env.WebRootPath = "C:\\Users\\jch\\source\\repos\\Rapiscan264-3\\WebApplicationSourceCode\\wwwroot";
            env.ContentRootPath = "C:\\Users\\jch\\source\\repos\\Rapiscan264-3\\WebApplicationSourceCode";

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }
            app.UseMvc();
        }
    }
}