Click here to Skip to main content
12,627,377 members (35,951 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET C#3.5
public string Get_real_IP(string Provider)
{
	HttpWebRequest SendReq = HttpWebRequest.Create(Provider);
	HttpWebResponse GetRes = SendReq.GetResponse();
 
	System.IO.Stream StreamRes = GetRes.GetResponseStream;
	StreamReader ResStrmRdr = new StreamReader(ResStream, Encoding.UTF8);
 
	string IP = ResStrmRdr.ReadToEnd;
 
	StreamRes.Close();
	GetRes.Close();
 
	return IP;
}
Posted 11-Oct-11 1:18am
dreamz9829
Updated 11-Oct-11 1:22am
P.Salini14.9K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

string IP = GetIP();
 
    public string  GetIP()
    {
        string Str = "";
        Str = System.Net.Dns.GetHostName();
        IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(Str);
        IPAddress[] addr = ipEntry.AddressList;
        return addr[addr.Length - 1].ToString();
 
    }
  Permalink  
Comments
asmaa elbattanony 25-Jan-12 10:33am
   
Thanx Kishorekke
Your Solution Worked like a charm ^_^
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

public static string GetIpAddress()  // Get IP Address
{
    string ip = "";
    IPHostEntry ipEntry = Dns.GetHostEntry(GetCompCode());
    IPAddress[] addr = ipEntry.AddressList;
    ip = addr[2].ToString();
    return ip;
}
public static string GetCompCode()  // Get Computer Name
{
    string strHostName = "";
    strHostName = Dns.GetHostName();
    return strHostName;
}
  Permalink  
Comments
CHill60 30-Jul-13 11:08am
   
As per my earlier comment - did you realise this question is nearly 2 years old.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

string VisitorsIPAddr = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (VisitorsIPAddr != null || VisitorsIPAddr !=String.Empty)
                    {
                        VisitorsIPAddr = Request.ServerVariables["REMOTE_ADDR"];
                    }
you can get visitors ip address from this.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 7 Oct 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100