前往
大廳
主題

[ASP.NET C#] 取得客戶端IP及Port

我吃檸檬 | 2020-10-30 17:29:33 | 巴幣 2 | 人氣 497

取得客戶端IP及Port的方法

string port = Request.ServerVariables["REMOTE_PORT"];
string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ip))
{
ip = Request.ServerVariables["REMOTE_ADDR"];
}

附上其他檢視環境變數

創作回應

相關創作

更多創作