'一般使用取得IP的方法,
'取得ClientIP
ClientIP = Request.ServerVariables("REMOTE_ADDR").ToString()
'對於使用代理伺服器的IP取得方法,
'判斷是否使用代理伺服器,如無使用則會為空
Request.ServerVariables["HTTP_VIA"].ToString()
'如有使用代理伺服器則可用以下方法取得真實IP
Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString()
完整取得ClientIP的方法
Dim strIPAddr As String Dim id As Integer Dim ip As String If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" Or InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then Else End If '使用以下方法提取出IP ip = Mid(strIPAddr, 1, 30).Trim.ToString
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") - 1)
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") - 1)
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
留言列表