views:

69

answers:

2

How can I get hold of a user's GEO location within my ASP.NET application? I've noticed on browsers like Firefox and Google Chrome, I (as the user) am prompted as to whether or not to allow the site to have access to my location.

How can I achieve a similar thing to this?

+1  A: 

Use the regular HTML5 Geolocation tools to get the location and then use AJAX to send the location back to your ASP.NET Server Side code and update whatever client elements are necessary.

Justin Niessner
+2  A: 

The prompt you're seeing is shown when a site uses the Geolocation API. It's all JavaScript, so you don't need any kind of server support to use it. If you want the values on the server side, you can send them back using XMLHttpRequest or a simple form post.

Here's a demo with easy to read source code as well.

Matti Virkkunen
Cheers Matti, I didn't realise it was so simple!
Curt