Click here to Skip to main content
16,015,756 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I want to store user IP address into the Database when user register in to the site.

How to get Client IP in asp.net?

Thanks in Advance
Posted

1 solution

C#
HttpContext.Current.Request.UserHostAddress;

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


To get the IP address of the machine and not the proxy use the following code

C#
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
 
Share this answer
 
Comments
Tech Code Freak 29-Jul-11 10:30am    
My 5!
Manas Bhardwaj 29-Jul-11 10:33am    
thanks!

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