C# .NET - how to find ip Address location - Asked By aman on 09-Dec-11 04:31 AM

hi all,
 i want to find  the location of the IP Address using windows application......but cant find any method to do soo.

so please help
if possible with some example.

Suchit shah replied to aman on 09-Dec-11 04:35 AM

You can try this




See http://www.maxmind.com/app/ip-location

Example: http://forum.maxmind.com/viewtopic.php?t=1151
Try out this - http://www.dotnetcurry.com/ShowArticle.aspx?ID=325

Suchit shah replied to aman on 09-Dec-11 04:36 AM

string sIp = Request.UserHostAddress;

Dim sIp As String = Request.UserHostAddress

To convert IP address into location, go to www.dnnsstuff.com
However IP address lookup is not always reliable e.g.

  • IP Addresses got from a pool
  • IP addresses for Manager user although in reality fixed, may be attributed to country of service provider not the actual country.
Jitendra Faye replied to aman on 09-Dec-11 04:36 AM
using System.Net;
IPHostEntry he = Dns.GetHostByName(Dns.GetHostName());
Text = he.AddressList[0].ToString(); // returns IP address

TRy this and lte me know.
dipa ahuja replied to aman on 09-Dec-11 05:39 AM
void getClientInfo()
  string RemoteIp = Request.UserHostAddress.ToString();
  string DNSName = Request.UserHostName;
  string user = HttpContext.Current.Request.UserHostAddress;
  Response.Write("</br>Remote Ip:" + RemoteIp);
  Response.Write("</br>DNS Name :" + RemoteIp);
  Response.Write("</br>" + Environment.MachineName.ToString());
  Response.Write("</br>  User:" + user.ToString());
  Response.Write("</br>" + Environment.UserName.ToString());
  Response.Write("</br>" + System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());