網(wǎng)站放到外網(wǎng)如何獲取訪問的客戶端IP呢?請(qǐng)大家支支招吧,謝啦!
2 回答

至尊寶的傳說
TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊
public static string GetClientIP() { string clientIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(clientIP)) clientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (string.IsNullOrEmpty(clientIP)) clientIP = HttpContext.Current.Request.UserHostAddress; if (string.IsNullOrEmpty(clientIP)) clientIP = "0.0.0.0"; return clientIP; }
- 2 回答
- 0 關(guān)注
- 646 瀏覽
添加回答
舉報(bào)
0/150
提交
取消