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

前端 未结 2 1641
暖寄归人
暖寄归人 2021-01-06 16:05

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 wheth

相关标签:
2条回答
  • 2021-01-06 16:39

    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.

    0 讨论(0)
  • 2021-01-06 16:46

    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.

    0 讨论(0)
提交回复
热议问题