Solved

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

Posted on 2010-11-17
9
1,372 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
  • 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
 
LVL 3

Expert Comment

by:rdmustang
ID: 34158599
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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 discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now