manohar vakkala

manohar vakkala

  • NA
  • 72
  • 142.4k

Tracking IP Address

Mar 30 2011 12:03 AM
Hi All,

I want to track the user IP address.

I have tried using DNS & Request objects to get the user IP address. Its working only in local PC not in server. May be this is because i'm missing a step to implement in server.

So, Please give me a solution other than using DNS & Request objects (or) please explain me how to implement this DNS & Request.


Thanks All,
Manohar

Answers (2)

0
Crish

Crish

  • 0
  • 2.4k
  • 91.8k
Mar 30 2011 1:32 AM
  1. Dim strClientIP As String
  2. strClientIP = Request.UserHostAddress()
  3. Response.Write(strClientIP)
0
Krishna Garad

Krishna Garad

  • 0
  • 15.6k
  • 8.5m
Mar 30 2011 12:31 AM
Check this sample
(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.whatismyip.org");

            request.UserAgent = "User-Agent: Mozilla/4.0 (compatible; MSIE" +

                "6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

            System.Net.HttpWebResponse response =

            (System.Net.HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader reader = new

            StreamReader(response.GetResponseStream()))
            {

               string myExternalIP = reader.ReadToEnd();

                reader.Close();

            }