EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

在 Visual Studio 2022 中配置 ASP.NET Web Form應用通過外部 IP 訪問的完整操作手順

1.設置項目綁定 (Bindings)

  • applicationhost.config 文件中,確認或添加以下 bindings 配置(\.vs\Your Project\config\applicationhost.config):
<bindings>
    <binding protocol="http" bindingInformation="*:42954:localhost" />
    <binding protocol="https" bindingInformation="*:44361:localhost" />
</bindings>

<bindings>
    <binding protocol="http" bindingInformation="*:42954:localhost" />
    <binding protocol="https" bindingInformation="*:44361:localhost" />  
    <binding protocol="http" bindingInformation="*:42954:127.0.0.1" />
    <binding protocol="https" bindingInformation="*:44361:127.0.0.1" />
    <binding protocol="http" bindingInformation="*:42954:192.168.11.120" />
    <binding protocol="https" bindingInformation="*:44361:192.168.11.120" />
</bindings>
  • 此配置允許通過 localhost127.0.0.1 和指定的內網 IP (192.168.11.120) 訪問該應用。

 

2.配置 Windows 防火牆

  • 確保 Windows 防火牆允許通過內網 IP 進行 HTTP 和 HTTPS 的流量。
  • 如果防火牆已關閉,可跳過此步驟;如防火牆開啟,需允許該應用的特定端口。

 

3.確認 URL ACL (Access Control List)

  • 打開命令提示符,輸入以下命令來檢查 URL ACL 設置:
netsh http show urlacl

如果需要添加或刪除 URL ACL 設置,請使用以下命令:

  • 添加:
netsh http add urlacl url=http://192.168.11.120:42954/ user=Everyone
netsh http add urlacl url=https://192.168.11.120:44361/ user=Everyone
  • 刪除:
netsh http delete urlacl url=http://192.168.11.120:42954/
netsh http delete urlacl url=https://192.168.11.120:44361/

很遺憾,目前 Windows 系統中並沒有提供專門的圖形界面來管理 URL ACL (Access Control List) 設置。您只能通過命令行使用 netsh http 命令來查看、添加或刪除 URL ACL 項

 

4. 測試外部 IP 訪問

  • 在本地網絡中的其他設備上,使用瀏覽器訪問應用,例如:
http://192.168.11.120:42954/FormSelectYoshiki.aspx
  • 確認應用是否能通過內網 IP 成功訪問。

 

通過以上步驟,即可在 Visual Studio 2022 中配置並允許 ASP.NET 應用通過內部網絡 IP 訪問。

This article was last edited at 2024-09-30 10:00:51

Today's comments have reached the limit. If you want to comment, please wait until tomorrow (UTC-Time).

There is 20h37m02s left until you can comment.