ASP得到当前页面完整地址

博主:jhchinajhchina 2023-01-11 289 0条评论
摘要: "http://" & Request.ServerVariables("HTTP_HOST") & Request.Ser...

"http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("PATH_INFO") & "?" & Request.ServerVariables("QUERY_STRING")

Request.ServerVariables("HTTP_HOST") '得到域名

Request.ServerVariables("PATH_INFO") '得到当前文件路径

"?" & Request.ServerVariables("QUERY_STRING") '得到参数


做asp程序的时候,有时候需要用的着!

dim url

url=url&"http://"&request.ServerVariables("Server_NAME")&request.ServerVariables("SCRIPT_NAME")

if(len(trim(request.ServerVariables("QUERY_STRING")))>0) then

url=url & "?" & request.ServerVariables("QUERY_STRING")

end if

response.Write url


获取IP的函数

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

文章最后编辑时间:2023-01-14 19:22:48