简体   繁体   English

在asp.net或javascript中如何获取Lan IP而不是公共IP

[英]How to get Lan IP not public IP in asp.net or javascript

My local IP address in 192.168.0.11. 我的本地IP地址在192.168.0.11中。 How can i get this using ASP.NET or Javascript. 我如何使用ASP.NET或Javascript获得此信息。

Currently i am using the below which returns my Public IP Address 目前,我正在使用下面的方法返回我的公共IP地址

Dim ip As String = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")

i googled many times but every method i got returns my Public IP. 我搜索了很多遍,但是我得到的每种方法都会返回我的公共IP。

Is it possible to get this info using asp.net or javascript. 是否有可能使用asp.net或javascript获取此信息。

You can't. 你不能 Client-side JavaScript doesn't deal with IP's at all, and server-side languages really have no access to local IP's for the simple reason that this data is not being sent to the server. 客户端JavaScript根本不处理IP,并且服务器端语言实际上无法访问本地IP,原因很简单,因为该数据未发送到服务器。

If you really want to obtain the local IP, you're going to have to get the user to install some kind of software on their PC. 如果您确实想获取本地IP,则必须让用户在其PC上安装某种软件。

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

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