Solved

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

Posted on 2010-11-17
9
1,418 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…
Suggested Courses

630 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