1. programming 1.1 C# 1.2 ASP.NET Core

kestral 監聽 localhost 沒辦法透過區域網路讓其他客戶端訪問

2024 年 3 月 6 日

檔案appsettings.json


{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "Kestrel": {
    "EndPoints": {
      "Http": {
        //"Url": "http://localhost:7861/" //只有本機才可連線到localhost:7861或127.0.0.1:7861
        //"Url": "http://127.0.0.1:7861/" //只有本機才可連線到localhost:7861或127.0.0.1:7861
        "Url": "http://192.168.0.100:7861/" //綁定到192.168.0.100:7861,區域網路才可以訪問
      }
    }
  },
  "AllowedHosts": "*"
}

參考資料:

  1. Note to self: localhost in kestrel is localhost | Azure Coding Architect
  2. 指定 ASP.NET Core Kestrel 接聽 Port-黑暗執行緒 (darkthread.net)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *