我正在使用ASP.NET Core 2.0.0,并使用它创建了一个可在HTTPS中运行的Web应用程序。为了在HTTPS中运行,我在我的Program.cs文件中使用了以下代码:
string directory = Directory.GetCurrentDirectory();
string portNumber = Helper.getPortNumber(directory);
var cert = new X509Certificate2("file1.pfx", "ccc");
var host = new WebHostBuilder()
.UseKestrel(cfg => cfg.UseHttps(cert))
.UseUrls("https://localhost:53135")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
然后将APPURL更改为https://localhost:53135/。如果我运行程序,会出现以下错误:
"An error occurred attempting to determine the process id of service.exe which is hosting your application.One or more errors occurred."
但如果我将端口号设置为 44300 至 44399,就不会出现任何异常,并且链接可以成功托管。我在一篇链接中读到,要运行带有 SSL 的 IIS Express,端口号应该在 44300 到 44399 的范围内。我需要在所有端口上运行我的应用程序。请有人指导我如何做到这一点?