gpt4 book ai didi

带 Core 2.0 的 SSL 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 13:33:41 25 4
gpt4 key购买 nike

Visual Studio 2017 15.4IIS ExpressCORE 2.0 MVCWin 7 Ultimate

我用 Core 2.0 创建了一个新的 MVC 项目。没有 SSL,它运行良好:

LaunchSettings.json

       {
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58087/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MVCIdenWebApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:58088/"
}
}
}

当我将其设置为使用 SSL 时,出现 Vis Stud 错误:无法连接到 Web 服务器 IISExpress

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:58087/",
"sslPort": 44335
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MVCIdenWebApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:58088/"
}
}
}

Program.cs

public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}

我在 CORE 1.1 项目中使用 SSL 没有问题,但在任何 CORE 2.0 项目中都会遇到同样的错误。

我已经尝试删除解决方案的 .vs 文件夹MyDocmuents\IIExpress 文件夹的内容。

Partial Solution:

当我使用 sslPort 添加“launchUrl”:到 IIS Express 配置文件时,应用程序将在该地址(而不是应用程序 URL)打开:“launchUrl”:“https://localhost:44335”,

这与 CORE 1.1 不同,我不知道这是否是官方方法,因为我无法找到任何关于如何在 Core 2.0 应用程序中启用 SSL 的文档.

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:58087/",
"sslPort": 44335
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "https://localhost:44335/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MVCIdenWebApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:58088/"
}
}
}

最佳答案

我有类似设置配置的“无法连接到 Web 服务器 IISExpress”。

对我来说,修复是通过提升的 cmd 提示删除 urlacl。

netsh http show urlacl
netsh http delete urlacl https://machine:iisexpressport/

关于带 Core 2.0 的 SSL 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46965556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com