asp中怎样获取访问者的IP地址?

2024-11-11 07:18:49
推荐回答(3个)
回答1:

ip = request.servervariables("remote_addr") '获取访问者的ip
now_time = now '获取登陆时间(服务器时间)

完整的代码如下
dim
conn,rs,ip,now_time
set
conn=server.createobject("adodb.connection")
dbpath =
server.mappath("数据库路径")
conn.open "driver={microsoft access driver
(*.mdb)};dbq=" & dbpath
set
rs=server.createobject("adodb.recordset")
sql = "表名"
rs.open
sql,conn,3,2
rs.addnew
ip = request.servervariables("remote_addr")
'获取访问者的ip
now_time = now '获取登陆时间(服务器时间)
rs("字段名1") = ip
rs("字段名2") = now_time
rs.update

回答2:

Request.ServerVariables("REMOTE_ADDR")

回答3:

Request.ServerVariables("HTTP_X_FORWARDED_FOR")
Request.ServerVariables("REMOTE_ADDR")