asp.net - 尽管启用了 SSL,但获取 "Firefox can’ t 建立与本地主机服务器的连接

标签 asp.net asp.net-mvc ssl visual-studio-2017

我正在使用 ASP.NET Core 中的Individual User Account 身份验证方法创建具有Identity 的 ASP.NET Web 应用程序:

enter image description here

当我运行应用程序时,我在浏览器中收到错误消息:

Unable to connect: Firefox can’t establish a connection to the server at localhost:44330. ...

在我寻找解决方案的过程中,我发现禁用 SSL 可能会导致此问题,但默认情况下它是启用的。

我还添加了:

services.Configure<MvcOptions>(options =>
{
    options.Filters.Add(new RequireHttpsAttribute());
});

public void ConfigureServices(IServiceCollection services) 方法并添加:

var options = new RewriteOptions()
            .AddRedirectToHttps();

        app.UseRewriter(options);

public void Configure(IApplicationBuilder app, IHostingEnvironment env) 方法

我根据搜索解决方案时获得的信息尝试的其他事情

  • 我还安装了URL Rewrite
  • 尝试了不同的浏览器
  • 检查我的浏览器是否允许通过防火墙

都没有运气。

最佳答案

经过数小时的试验和错误后,我能够按照以下步骤在 Chrome 上运行我的网络应用程序:

对于 Chrome

  1. chrome://net-internals/#hsts 复制并粘贴到您的浏览器 (Chrome) 中,然后点击运行
  2. 在打开的页面中,找到 Delete domain security policies 在域字段中输入 localhost,然后点击删除。

enter image description here

该应用现在可以在 Chrome 上运行。我会在找到适用于所有浏览器的解决方案后立即更新这篇文章。

我还发现启动浏览器 url 必须与 Enable SSL 复选框中指定的 url 必须匹配:

enter image description here

要到达此处,右键单击“项目”->“属性”->“调试”

关于asp.net - 尽管启用了 SSL,但获取 "Firefox can’ t 建立与本地主机服务器的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47349070/

相关文章:

Javascript 验证文本框中的特定字符串

c# - 如何将 gridview 的形状更改为圆形?

c# - 路由问题 MVC4

asp.net-mvc - @Html.ActionLink 如何添加查询字符串

Razor MVC 中 C# 语句中的 JavaScript 变量

ssl - 从 https ://. .. 移动到 http://而不会中断链接(SSL 迁移)

ssl - Heroku 应用程序错误连接错误 : SSL_connect: certificate verify failed

url - SSL 是否保护 uri 中 @ 之前的部分?

c# - 通过交换服务器发送电子邮件问题。 (system.net.mail 与 microsoft.exchange.webservices)

asp.net - Web 部署错误到 IIS - 应用程序池 ManagedRuntimeVersion