📄 asp如何取真ip地址.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0052)http://www.meetchinese.com/earticles/show.cgi?id=907 -->
<HTML><HEAD><TITLE>ASP如何获取真实IP地址 - 读者网摘</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE>TD {
FONT-SIZE: 14px
}
LI {
FONT-SIZE: 14px
}
SELECT {
FONT-SIZE: 14px
}
INPUT {
FONT-SIZE: 14px
}
.f7 {
FONT-SIZE: 7px
}
.f24 {
FONT-SIZE: 24px
}
.f14 {
FONT-SIZE: 14px
}
.l17 {
LINE-HEIGHT: 170%
}
A:link {
COLOR: #0000ff
}
A:visited {
COLOR: #800080
}
A:active {
COLOR: #ff0000
}
A:hover {
COLOR: #ff0000
}
A.a01:link {
COLOR: #07015b; TEXT-DECORATION: none
}
A.a01:visited {
COLOR: #07015b; TEXT-DECORATION: none
}
A.a01:active {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.a01:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.a02:link {
COLOR: #0000ff; TEXT-DECORATION: none
}
A.a02:visited {
COLOR: #0000ff; TEXT-DECORATION: none
}
A.a02:active {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.a02:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.sp1:link {
COLOR: #0000ff; TEXT-DECORATION: none
}
A.sp1:visited {
COLOR: #0000ff; TEXT-DECORATION: none
}
A.sp1:active {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.sp1:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
.bsgb {
COLOR: #ffffff; FONT-SIZE: 12px; TEXT-DECORATION: none
}
A.bsgb:link {
COLOR: #ffffff; FONT-SIZE: 12px; TEXT-DECORATION: none
}
A.bsgb:visited {
COLOR: #ffffff; FONT-SIZE: 12px; TEXT-DECORATION: none
}
A.bsgb:active {
COLOR: #ffffff; FONT-SIZE: 12px; TEXT-DECORATION: none
}
A.bsgb:hover {
COLOR: #ffffff; FONT-SIZE: 12px; TEXT-DECORATION: none
}
.x14 {
FONT-SIZE: 14px; LINE-HEIGHT: 130%
}
.title12 {
FONT-SIZE: 12px
}
.title14 {
FONT-SIZE: 14px; LINE-HEIGHT: 130%
}
P {
FONT-SIZE: 14px; LINE-HEIGHT: 170%
}
</STYLE>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=5 topMargin=5 marginheight="5" marginwidth="5">
<SCRIPT language=javascript>function sendmail(id){window.open("http://www.meetchinese.com/earticles/mail.cgi?id="+id,"","height=240,width=470,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");}function review(id){window.open("http://www.meetchinese.com/earticles/review.cgi?action=show&id="+id,"","height=500,width=550,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");}function checksearch(){ if (document.search.key.value=="") { alert("请输入想查询的内容!"); document.search.key.focus(); return false; } return true;}</SCRIPT>
<DIV align=center>
<TABLE border=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD width="100%">您的位置: <A
href="http://www.meetchinese.com/">MeetChinese.com</A> > <A
href="http://www.meetchinese.com/earticles/main.cgi">读者网摘</A> > <A
href="http://www.meetchinese.com/earticles/list.cgi?class=9">ASP</A> >
<A
href="http://www.meetchinese.com/earticles/list.cgi?class=9&type=79">ASP技巧</A>
> 正文 -- <A
href="javascript:window.external.AddFavorite('http://www.meetchinese.com/earticles/show.cgi?id=907', 'ASP如何获取真实IP地址')"
target=_self>收藏本文</A>
<HR noShade SIZE=1>
</TD></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 cellSpacing=0 height=237 width=750>
<TBODY>
<TR>
<TD height=%100 vAlign=top width=590>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD width="100%">
<P align=center><SPAN class=title>ASP如何获取真实IP地址</SPAN> </P></TD></TR>
<TR>
<TD width="100%"><IMG height=5
src="ASP如何取真IP地址 - 者网摘.files/space.gif" width=1></TD></TR>
<TR>
<TD vAlign=center width="100%">
<DIV align=center>wjdh 11-08-2001 21:28:53 阅读2049次 <SPAN><A
href="http://www.meetchinese.com/earticles/show.cgi?id=906"
title=ASP动态Include文件>上一篇</A></SPAN> <SPAN><A
href="http://www.meetchinese.com/earticles/show.cgi?id=908"
title=在网页中调用本地的应用程序>下一篇</A></SPAN></DIV></TD></TR>
<TR>
<TD vAlign=center width="100%"><IMG height=5
src="ASP如何取真IP地址 - 者网摘.files/space.gif" width=1></TD></TR>
<TR>
<TD bgColor=#808080 width="100%"><IMG height=1
src="ASP如何取真IP地址 - 者网摘.files/space.gif" width=1></TD></TR>
<TR>
<TD width="100%"><IMG height=5
src="ASP如何取真IP地址 - 者网摘.files/space.gif" width=1></TD></TR>
<TR>
<TD class=text width="100%"> 在 ASP 中使用
Request.ServerVariables("REMOTE_ADDR") 来取得客户端的 IP
地址,但如果客户端是使用代理服务器来访问,那取到的就是代理服务器的 IP 地址,而不是真正的客户端 IP
地址。要想透过代理服务器取得客户端的真实 IP 地址,就要使用
Request.ServerVariables("HTTP_X_FORWARDED_FOR") 来读取。
<BR> 不过要注意的事,并不是每个代理服务器都能用
Request.ServerVariables("HTTP_X_FORWARDED_FOR") 来读取客户端的真实
IP,有些用此方法读取到的仍然是代理服务器的 IP。 <BR> 还有一点需要注意的是:如果客户端没有通过代理服务器来访问,那么用
Request.ServerVariables("HTTP_X_FORWARDED_FOR")
取到的值将是空的。因此,如果要在程序中使用此方法,可以这样处理: <BR><BR>...... <BR>userip =
Request.ServerVariables("HTTP_X_FORWARDED_FOR") <BR>If userip = ""
Then userip = Request.ServerVariables("REMOTE_ADDR") <BR>......
<BR><BR> 即:如果客户端通过代理服务器,则取 HTTP_X_FORWARDED_FOR 的值,如果没通过代理服务器,就取
REMOTE_ADDR 的值。 </TD></TR>
<TR>
<TD width="100%">
<DIV align=right><INPUT name=button onclick="document.location.href='javascript:sendmail(907)'" type=button value=推荐给朋友>
<INPUT name=button onclick=javascript:window.print() type=button value=打印本页>
<INPUT name=button onclick=window.close() type=button value=关闭窗口></DIV></TD></TR>
<TR>
<TD width="100%">
<HR noShade SIZE=1>
</TD></TR>
<TR>
<TD class=review width="100%">在此发表你对本文的意见和看法(800字以内) <A
href="javascript:document.review.submit()">发表</A></TD></TR>
<TR>
<TD class=review width="100%"><IMG height=5
src="ASP如何取真IP地址 - 者网摘.files/space.gif" width=1></TD></TR>
<TR>
<FORM action=review.cgi name=review>
<TD class=review width=590><TEXTAREA cols=70 name=text rows=5></TEXTAREA> <INPUT
name=action type=hidden value=new> <INPUT name=id type=hidden
value=907> </TD></FORM></TR>
<TR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -