如何在ASP.NET中使用客户端脚本获取Visior IP地址 [英] How to get visior ip address using client side script in asp.net
本文介绍了如何在ASP.NET中使用客户端脚本获取Visior IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何使用javascript ..
获取asp.net中的访问者IP地址.
我尝试了太多.但我无法找到确切的解决方案.
请任何人帮助我.
谢谢
S.vinodkumar
hi Guys,
How to get visitor ip address in asp.net using javascript ..
I tried too much . but I cant get exact solution.
Please help me any one..
Thank you
S.vinodkumar
推荐答案
您无法在客户端获取IP地址-您必须引用服务器.客户端IP是不延伸通过路由器的本地地址(192.xxx.xxx.xxx或类似地址).同样,服务器看不到客户端的实际IP,而是看到由ISP分配的实际路由器的IP地址.
最简单的方法是询问服务器:
You can''t get the IP address at the client side - you have to refer to the server. The Client side IP is a local address (192.xxx.xxx.xxx or similar) which does not extend past the router. Equally, the Server cannot see the Client actual IP - it sees the IP address of the actual router, which is assigned by the ISP.
The easiest way to do it is to ask the server:
<br />Your IP address is <%= Request.ServerVariables["REMOTE_ADDR"] %><br />
试试这个
Try this one
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript" >
function ClientIP()
{
.getJSON("http://jsonip.appspot.com?callback=?",函数(jsonResult){
.getJSON("http://jsonip.appspot.com?callback=?", function (jsonResult) {
这篇关于如何在ASP.NET中使用客户端脚本获取Visior IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文