且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ASP.NET中使用客户端脚本获取Visior IP地址

更新时间:2021-07-06 22:05:31

您无法在客户端获取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) {