Curtis
Curtis

Reputation: 103338

How can I find a user's GEO Location using ASP.NET?

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?

Upvotes: 5

Views: 10180

Answers (2)

Matti Virkkunen
Matti Virkkunen

Reputation: 65116

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.

Upvotes: 6

Justin Niessner
Justin Niessner

Reputation: 245389

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.

Upvotes: 5

Related Questions