Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
i have a website. I want to get all visitor's ip address in the moment. Please help me.
Posted
Comments
phil.o 28-May-14 19:54pm    
Mohammed Nabeel Khan 28-May-14 20:03pm    
this is my first question and i really need help mr. phil . . . .

http://www.codeproject.com/Questions/779341/Remote-desktop-control-application-on-windows-form?arn=3

phil.o 28-May-14 20:12pm    
No, what you need is to learn how to approach problems, instead of asking for some ready made working code.
Please see my comment on your other post. Both links provided should be read very carefully.
Mohammed Nabeel Khan 28-May-14 21:09pm    
with respect i did'nt ask for code but could'nt explain what i needed.
i have posted another question .

C#
System.Web.HttpContext context = System.Web.HttpContext.Current;
   string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

   if (!string.IsNullOrEmpty(ipAddress))
   {
       string[] addresses = ipAddress.Split(',');
       if (addresses.Length != 0)
       {
           return addresses[0];
       }
   }

   return context.Request.ServerVariables["REMOTE_ADDR"];
}
 
Share this answer
 
C#
string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
    ipaddress = Request.ServerVariables["REMOTE_ADDR"];


or equavalent code can be written in vb
 
Share this answer
 
Comments
nguyenvanngon 29-May-14 4:38am    
i want to get all visitor's ip address. Exam: i have 2 visitor's ip address: 192.168.1.1 and 192.168.4.100. So in the result (in label, textbox...) show : 192.168.1.1 and 192.168.4.100. Please help me!!!

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