我可以使用HttpListener來偵聽來自同一臺計算機的請求,但我還沒有想出如何讓它監聽外部請求。HttpListener不在主機之外監聽?
我的前綴是: 「http://192.168.103.82:5000/」
我也試過: 的 「http:// *:5000 /」
我可以輸入我的地方網絡IP到瀏覽器並獲得響應。但是如果我在同一個網絡上的不同計算機上做同樣的事情,就沒有這樣的運氣。
是否需要額外配置一些配置?這是一個操作系統特定的問題?我正在運行Windows 7 Home。
我可以使用HttpListener來偵聽來自同一臺計算機的請求,但我還沒有想出如何讓它監聽外部請求。HttpListener不在主機之外監聽?
我的前綴是: 「http://192.168.103.82:5000/」
我也試過: 的 「http:// *:5000 /」
我可以輸入我的地方網絡IP到瀏覽器並獲得響應。但是如果我在同一個網絡上的不同計算機上做同樣的事情,就沒有這樣的運氣。
是否需要額外配置一些配置?這是一個操作系統特定的問題?我正在運行Windows 7 Home。
您需要通過Windows防火牆允許端口5000。
從命令:netsh http add urlacl
以下命令可用:
命令在這方面:加cacheparam - 增加HTTP服務緩存 參數添加iplisten - 增加一個IP地址的IP聽名單。 add sslcert - 爲IP地址和端口添加一個SSL服務器證書綁定。添加超時 - 向 服務添加全局超時。添加urlacl - 添加一個URL預訂條目。 PS C:\ Users \ dwalker> netsh http add urlacl?
用法:加urlacl的[url =] [USER =] [聽=]是|否[委託=]是|否] | [SDDL =] ]
參數:
Tag Value url - The fully qualified URL user - The user or user-group name listen - One of the following values: yes: Allow the user to register URLs. This is the Default value. no: Deny the user from registering URLs delegate - One of the following values: yes: Allow the user to delegate URLs no: Deny the user from delegating URLs. This is the default value. sddl - SDDL string that describes the DACL
說明:該命令保留的URL,非管理員用戶和 賬戶。可以通過使用NT帳戶名稱 與listen和delegate參數或使用SDDL字符串來指定DACL。
實施例:
add urlacl url=http://+:80/MyUri user=DOMAIN\user add urlacl url=http://www.contoso.com:80/MyUri user=DOMAIN\user listen=yes add urlacl url=http://www.contoso.com:80/MyUri user=DOMAIN\user delegate=no add urlacl url=http://+:80/MyUri sddl=...
例如:netsh http add urlacl user=Everyone url="http://192.168.103.82:5000/"