Forums - C# Corner

Forum guidelines
Sonu Pandey

Sonu Pandey

  • 1.5k
  • 6
  • 725

How to get Visitor IP Address and Location in ASP.Net

Aug 6 2016 4:33 AM
 
I am using this code but this is not show Visitor IP Address 
 
string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
{
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write(ipaddress);
 
Please help me  

Answers (8)