获取客户端IP地址及其登录我的Web应用程序的位置 [英] Get Client IP Address and His location for where he login to my web application

查看:93
本文介绍了获取客户端IP地址及其登录我的Web应用程序的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,每个人,
在我的项目中,我想跟踪用户或客户从何处登录.我需要获取IP地址,位置之类的参数
(纬度,经度),那么如何在我的Web应用程序中获取这两个参数....


1. IP地址
2.位置

在此先感谢,
Arun RV

Hello Every one,
In my project I want to keep the track of users or Client from where did he logged in . I need to get parameter like IP address , location
(latitude,longitude) so how can i get that two parameter in my Web application....


1. IP Address
2. Location

Thanks in Advance,
Arun R.V

推荐答案

客户端IP非常简单: ^ ]可以做到:
位置比较难,而且可能根本不准确,但是您可以尝试使用以下API: http://www.hostip.info/use .html [ ^ ]-可能会被警告不行.我当前的IP返回为实际上我们没有线索",但是由于ISP分配了动态IP,因此它已经在几百英里之外的国家/地区了.
Client IP is pretty easy: HttpContext.Current.Request.UserHostAddress[^] will do it:
Location is harder, and may not be at all accurate, but you can try this API: http://www.hostip.info/use.html[^] - be warned, it may not work. My current IP comes back as "Actually we haven''t a clue", but since dynamic IPs are allocated by the ISP it has been in countries a couple of hundred miles away.


两种方法为您解决问题

常见步骤:
获取客户端IP:
Two Methods for you problem

Common Step:
Get Client IP:
Request.ServerVariables["HTTP_X_FORWARDED_FOR"]

Request.ServerVariables["REMOTE_ADDR"]

(一个用于普通访问,另一个用于代理访问.

1.然后,您可以获取ip列表的数据库并将其添加到数据库中,并根据ip获取详细信息.链接:(忘记了链接)

2.使用地理字节Web服务获取ip详细信息.
例如:

(one for normal access and other for proxy access.

1. Then you can either get the database of ip list and add it in your database and get the details according to the ip. Link:(forgot the link)

2. Use geo bytes web service to get ip details.
Ex:

var etime_url = 'http://gd.geobytes.com/Gd?after=-1&variables=GeobytesCountry,GeobytesCity,GeobytesRegion';
    AjaxCallFullUrl( etime_url, 'geolocation');
    setTimeout("generateLocation()",2000);



祝您编码愉快……



Happy Coding......


获取IP尝试一下...

http://www.dotnetperls.com/ip [ http://www.hanselman.com/blog/TheWeeklySourceCode37GeolocationGeotargetingReverseIPAddressLookupInASPNETMVCMadeEas http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/ [ ^ ]

http://stackoverflow.com/questions/372591/how-to-get-city-country-and-country-code-for-a-particular-ip-address-in-asp-ne [
For getting IP Try this...

http://www.dotnetperls.com/ip[^]

Form IP to location it helps you...

http://www.hanselman.com/blog/TheWeeklySourceCode37GeolocationGeotargetingReverseIPAddressLookupInASPNETMVCMadeEasy.aspx[^]

Others...

http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/[^]

http://stackoverflow.com/questions/372591/how-to-get-city-country-and-country-code-for-a-particular-ip-address-in-asp-ne[^]


这篇关于获取客户端IP地址及其登录我的Web应用程序的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆