Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all friends
plz i need to know how i get the IP adress of the remote user to use it in my code
thx
Posted

Your code will need to examine the IP Packet Header[^] received when the user first connects, then extract the source IP address. If you need the port number as well, you'll have to look at the TCP packet that follows the IP information.
 
Share this answer
 
httpcontext.current.request.UserHostAddress
 
Share this answer
 
There are couple of ways to get IP address.

HttpContext.Current.Request.UserHostAddress;

or
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];


If you want IP Address of the machine, regardless of the proxy settings, you can go for :
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR");
 
Share this answer
 
Comments
raju melveetilpurayil 6-Sep-10 2:25am    
Reason for my vote of 5
good ;)
Abhishek Sur 11-Sep-10 15:27pm    
Most welcome my friend.
You cannot find an IP address without some information. You can send a 'ping' to a remote user, but you need either the machine's IP address or its full internet name.
 
Share this answer
 
<code>

httpcontext.current.request.UserHostAddress
</code>
 
Share this answer
 
Comments
raju melveetilpurayil 6-Sep-10 2:27am    
Reason for my vote of 1
do not add same answer in multiple times.
<pre lang="vb">httpcontext.current.request.UserHostAddress

 
Share this answer
 
Comments
raju melveetilpurayil 6-Sep-10 2:24am    
Reason for my vote of 1
do not add same answer in multiple times.

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