Solved

how to get ip address location in asp.net c# .net

Posted on 2010-11-17
9
1,398 Views
Last Modified: 2013-12-17
hi,

I have returned an host ip address from:

so I wanna detect the location of that ip address, such as USA, NY, New York City

how can I do that in asp.net?
0
Comment
Question by:njgroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 3

Assisted Solution

by:rdmustang
rdmustang earned 75 total points
ID: 34157455
You can purchase 3rd party databases for IP address but they do change.

You might also script a lookup against a website that provides this information such as http://www.ip2location.com/free.asp

If you use a website then please check with the owner to make sure it's ok for you to query against it.
0
 
LVL 20

Assisted Solution

by:Proculopsis
Proculopsis earned 75 total points
ID: 34157506

Subscribe to a service like:

<form action="http://www.ipaddresslocation.org/ip-address-locator.php" method="POST">      	
                
<input type="text" name="ip" value="132.163.4.22" size="30" maxlength="16"> 

<input  type="submit" value="IP Locator" />

</form>

Open in new window

0
 

Author Comment

by:njgroup
ID: 34157725
thanks,

I wanna get the result in page load method instead of posting a form, isn't there any way to get a result in page load method?

    protected void Page_Load(object sender, EventArgs e)
    {
       // code to get location of remote host ip
    }
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Expert Comment

by:rdmustang
ID: 34158599
0
 

Author Comment

by:njgroup
ID: 34162247
thanks, but that doesn't help,

that works for get method, but not post!

how will I specify the IP address in post method?
0
 

Author Comment

by:njgroup
ID: 34162264
I mean that returns whole page!
in post method, how to specify parameter and get string of location only?
0
 
LVL 7

Expert Comment

by:kovilpattiBalu
ID: 34162552
hi,
 protected void chkIPAddress_Click(object sender, EventArgs e)
        {
            string hostName = Dns.GetHostName();            
            Console.WriteLine("Host Name = " + hostName);
            IPHostEntry local = Dns.GetHostByName(hostName);
            foreach (IPAddress ipaddress in local.AddressList)
            {
                Console.WriteLine("IPAddress = " + ipaddress.ToString());
                result = result + ipaddress.ToString();
            }
            txtBrowser.Text = result ;
        }

http://www.codeproject.com/KB/IP/obafindingipinformation.aspx
0
 
LVL 7

Accepted Solution

by:
kovilpattiBalu earned 350 total points
ID: 34162575
0
 

Author Closing Comment

by:njgroup
ID: 34180143
that's great, but do u have a db for cities free?
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question