标题:ASP新手求教,如何获取客户端IP?
取消只看楼主
asp_user
Rank: 2
等 级:论坛游民
帖 子:13
专家分:10
注 册:2012-12-28
结帖率:25%
已结贴  问题点数:10 回复次数:0 
ASP新手求教,如何获取客户端IP?
我在网上找了两段代码

  一个是:
  ip = request.servervariables("http_x_forwarded_for")
  if ip = "" then
  ip = Request.ServerVariables("Remote_Addr")

  另一个是:
  Private Function getIP()
  Dim strIPAddr
  If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
  strIPAddr = Request.ServerVariables("REMOTE_ADDR")
  ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
  strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
  ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
  strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
  Else
  strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  End If
  getIP = Trim(Mid(strIPAddr, 1, 30))
  End Function


  以上两段代码,无论哪一个我放在网站中后,它得到的都是网站的IP而不是访问网站的人的客户客户端的IP,想请教一下如何才能得到客户端的IP?谢谢!!!
搜索更多相关主题的帖子: 客户端 如何 
2012-12-28 10:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-394183-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.643197 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved