Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Hosting a web site and i want my clients pc's ip address and pc name in my website's server side vb.net code i tried code of [REMOTE_ADDR] and System.Net.IPAddress(.AddressList(0).Address)but it returns the server address i want clients pc name and address
please help me

Devang Vaja
Posted

In ASP.NET
VB
Request.UserHostAddress; //property
//Or
Request.ServerVariables("REMOTE_ADDR"); //method


Hope it helps in any way.
 
Share this answer
 
v2
Comments
OriginalGriff 29-Aug-12 10:13am    
Um.
Request.UserHostAddress is not a method - it's a read-only property.
Christian Amado 29-Aug-12 10:15am    
Yes, sorry. I write quickly :)
You can get the Client IP address: Request.UserHostAddress will give it to you.

However, they is probably not the actual IP address of the client PC, and you can't get that or the PC name. The IP you get will be the IP of the ADSL connection device that transports between the internet (via the ISP) and the local PC on any internal network. The internal address is meaningless without access to the entire internal network, which you won't have, since it will probably be randomly assigned in the 192.x.x.x range.

Basically, you can't get what you want. The PC name is unavailable for security reasons, and the IP is unavailable because you have no access beyond the ADSL router to the local internal network.
 
Share this answer
 
Did you try [REMOTE_ADDR] exactly? Or did you try

Request.ServerVariables("remote_host")

http://www.w3schools.com/asp/coll_servervariables.asp[^]
 
Share this answer
 
i have tried
string PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName;
and
VB
With system.Net.DNS.GetHostByName(system.Net.DNS.GetHostName())
    sam = New System.Net.IPAddress(.AddressList(0).Address)
    sam1 = sam.ToString
End With

but it gives me server address
 
Share this answer
 
by request.userhostaddress i am getting 127.0.0.1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900