简体   繁体   English

获取客户的IP地址和国家/地区以及上一个点击页面的网址

[英]Get client ip address and country and previous click page url

I share my domain link in social media network. 我在社交媒体网络中共享我的域链接。 i want to monitor the users clicks the link from which social, media, their ip address, their country. 我想监视用户单击的链接,这些链接来自社会,媒体,他们的IP地址,他们的国家。 iam using the below code to get the info. 我使用下面的代码来获取信息。

Dim url As String = "http://ipinfo.io"
Try
    Dim request As WebRequest = WebRequest.Create(url)
    Dim ws As WebResponse = request.GetResponse()

    Dim jsonString As String = String.Empty
    Using sreader As System.IO.StreamReader = New System.IO.StreamReader(ws.GetResponseStream())
        jsonString = sreader.ReadToEnd()
    End Using
    Dim jsSerializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
    Dim Information As ClientInfo = jsSerializer.Deserialize(Of ClientInfo)(jsonString)
    Catch ex As Exception
End Try

but it gives me the info of the hosting ip address, and country of my site. 但是它为我提供了托管IP地址和网站所在国家/地区的信息。

The service you are trying to connect to, ipinfo.io, is used to get your ip information. 您尝试连接的服务ipinfo.io用于获取您的ip信息。 This is not useful when accessed server side. 当访问服务器端时,这没有用。 You will need to access this api on the client side and send this back to your server for logging. 您将需要在客户端访问此api,并将其发送回服务器进行日志记录。

An alternative can be found on this other answer How to get a user's client IP address in ASP.NET? 可以在此其他答案上找到替代方法。 如何在ASP.NET中获取用户的客户端IP地址?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM