簡體   English   中英

盡管啟用了SSL,但仍顯示“ Firefox無法在本地主機上建立與服務器的連接”

[英]Getting “Firefox can’t establish a connection to the server at localhost” despite having SSL enabled

我在ASP.NET Core中使用身份驗證的“ Individual User Account方法創建具有Identity的ASP.NET Web應用程序:

在此處輸入圖片說明

運行應用程序時,我在瀏覽器中收到錯誤消息:

無法連接:Firefox無法在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://net-internals/#hsts到瀏覽器(Chrome)中,然后點擊運行
  2. 在打開的頁面中,找到“ Delete domain security policies ”。在“域”字段中輸入localhost ,然后單擊“刪除”。

在此處輸入圖片說明

該應用程序現在可以在Chrome上運行。 一旦找到適用於所有瀏覽器的解決方案,我將立即更新此帖子。

我還發現啟動瀏覽器的網址必須與“ Enable SSL復選框中指定的網址匹配:

在此處輸入圖片說明

要到達此處, Right click on Project -> Properties -> Debug

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM