Click here to Skip to main content
15,883,769 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to get IP address of my website viwers and show it on label.
How it is possible? Anyone there who got an idea and like to help me... :)
Posted
Updated 28-Dec-10 5:07am

Hi,

HttpRequest.UserHostAddress

You can access the HttpRequest of your page using the Request property of your page.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Rezwan Ul 29-Dec-10 1:57am    
Thank you
C#
label1.Text = Request.UserHostAddress.ToString();
 
Share this answer
 
Comments
Rezwan Ul 29-Dec-10 0:48am    
working fine..:)
Try with the server variables as
HttpContext.Current.Request.UserHostAddress;
or
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
To get the IP address of the machine and not the proxy use the following code
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"
];
 
Share this answer
 
Comments
Rezwan Ul 29-Dec-10 2:29am    
working fine....:)
Brij 29-Dec-10 2:39am    
:)
See here[^].
That link goes into my bookmark as well.
:)
 
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