Forum Moderators: open

Message Too Old, No Replies

Display IP address using ASP

         

harry983

6:24 am on May 30, 2009 (gmt 0)



hello friends, I am going to design a website. I want to display the ip address of visitors on the web page. But I do not know how to display ip address of the visitors using asp. Can any one help me to display ip address of the visitors on the webpage of visitors.

[edited by: engine at 8:12 am (utc) on May 30, 2009]
[edit reason] See TOS [/edit]

incrediBILL

10:30 am on May 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Harry, welcome to WebmasterWorld and your questions would best be answered in the ASP forum:
[webmasterworld.com...]

Hope that helps as we have some real experts in the ASP community.

< admin note: the thread is now moved >

[edited by: tedster at 1:35 am (utc) on May 31, 2009]

jycting

12:35 am on May 31, 2009 (gmt 0)



Hello, friends, here are three ways you can look at
1: the current IP address and the online access time into the array ly.

Set ThisFile = StreamF.OpenTextFile (CountFile, 1, False)
Countly = 0
do while not ThisFile.AtEndOfStream
Thisline = ThisFile.readline
'Preserve the use of keywords, can only be adjusted on the final dimension of the array size, and can not change the dimension of the array.
'Only one-dimensional array, the Victoria is the last and only one-dimensional, you can modify the size of the array.
Redim preserve ly (Countly)
ly (Countly) = Thisline
'Countly documented that the number of rows ThisFile
Countly = Countly + 1
loop
ThisFile.Close

2: the beginning of the current page to refresh IP address access

sj in keeping the current system time
sameip = 0
for i = 1 to (Countly-1) / 2
'Access to even out
'If statistics online just now and the current IP address for more than a minute, then on from the IP
if DateDiff ( "s", ly (i * 2), sj)> 60 then
ly (i * 2-1) = ""
ly (i * 2) = ""
Countly = Countly-2
end if

'Just now, online access to the IP address, if it is online
'Request.ServerVariables ( "REMOTE_ADDR") issued a request for access to the machine IP
if Request.ServerVariables ( "REMOTE_ADDR") = ly (i * 2-1) then
sameip = 1
ly (i * 2) = sj
end if
next

3: access to the latest IP address of the current page into the People.asp

'Began to write the document data People.asp
set OutFile = StreamF.CreateTextFile (CountFile)
for i = 0 to Countly-1
if ly (i )<>"" then
outFile.WriteLine ly (i)
end if
next

if sameip = 0 then
outFile.WriteLine Request.ServerVariables ( "REMOTE_ADDR")
outFile.WriteLine sj
outFile.Close
end if

marcel

6:01 pm on May 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you only want to display the visitor IP address on your page, then the following is all you need:

[3]Response.Write(Request.Servervariables("REMOTE_ADDR"))[/3]