获取客户端的IP地址和PC名称 [英] get ip address and pc name of client

查看:177
本文介绍了获取客户端的IP地址和PC名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在托管一个网站,我希望我的客户的PC的IP地址和PC名称在我的网站的服务器端vb.net代码中,我尝试过[REMOTE_ADDR]和System.Net.IPAddress(.)的代码. AddressList(0).Address),但它返回服务器地址,我希望客户端的PC名称和地址
请帮助我

Devang Vaja

I am Hosting a web site and i want my clients pc''s ip address and pc name in my website''s server side vb.net code i tried code of [REMOTE_ADDR] and System.Net.IPAddress(.AddressList(0).Address)but it returns the server address i want clients pc name and address
please help me

Devang Vaja

推荐答案

在ASP.NET中
In ASP.NET
Request.UserHostAddress; //property
//Or
Request.ServerVariables("REMOTE_ADDR"); //method



希望对您有帮助.



Hope it helps in any way.


您可以获取客户端IP地址:Request.UserHostAddress会将其提供给您.

但是,它们可能不是客户端PC的实际IP地址,您无法获得该名称或PC名称.您获得的IP地址将是在Internet(通过ISP)和任何内部网络上的本地PC之间传输的ADSL连接设备的IP.内部地址没有访问整个内部网络的权限,这是没有意义的,因为您可能会在192.x.x.x范围内对其进行随机分配.

基本上,您无法获得想要的东西.出于安全原因,PC名称不可用,并且IP地址不可用,因为您无法通过ADSL路由器访问本地内部网络.
You can get the Client IP address: Request.UserHostAddress will give it to you.

However, they is probably not the actual IP address of the client PC, and you can''t get that or the PC name. The IP you get will be the IP of the ADSL connection device that transports between the internet (via the ISP) and the local PC on any internal network. The internal address is meaningless without access to the entire internal network, which you won''t have, since it will probably be randomly assigned in the 192.x.x.x range.

Basically, you can''t get what you want. The PC name is unavailable for security reasons, and the IP is unavailable because you have no access beyond the ADSL router to the local internal network.


您是否确实尝试过[REMOTE_ADDR]?还是您尝试过

Request.ServerVariables("remote_host")

http://www.w3schools.com/asp/coll_servervariables.asp [
Did you try [REMOTE_ADDR] exactly? Or did you try

Request.ServerVariables("remote_host")

http://www.w3schools.com/asp/coll_servervariables.asp[^]


这篇关于获取客户端的IP地址和PC名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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