asp.net中的IP地址 [英] Ip Address in asp.net

查看:76
本文介绍了asp.net中的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的系统上检索本地IP地址

google中的某些文章显示了一些方法,但是它不起作用.

请帮助我正确执行


我使用过的方式:

I want to retrieve the local IP address on my system

Some of the article in google shows some method,but its not working.

Please help me to do it correctly


The way i had used :

Request.Servervariables("REMOTE_ADDR")
Request.Servervariables("LOCAL_ADDR")



等等,但所有这些都给出了127.0.0.1

这是不正确的.请帮助


Kishore



etc,but all of it is giving 127.0.0.1

Its not correct. Kindly help


Kishore

推荐答案

如果使用的是开发服务器,则计算机的默认IP为127.0.0.1
在IIS中发布应用程序,然后可以使用Request.Servervariables("REMOTE_ADDR")
If you are using development server the default IP of your machine will be 127.0.0.1
Publish your application in IIS then you can get the IP adress of your machine using Request.Servervariables("REMOTE_ADDR")


hi来获取计算机的IP地址.
hi
Request.UserHostAddress;


希望对您有帮助..


I hope this may help you..


尝试以下代码:

要获取具有www地址的主机
Try this code :

To get a host with a www address
IPHostEntry ip = Dns.GetHostByName ("www.vbcity.com"); 
IPAddress [] IpA = ipE.AddressList; 
for (int i = 0; i < IpA.Length; i++) 
{ 
    Console.WriteLine ("IP Address {0}: {1} ", i, IpA[i].ToString ()); 
} 



获取本地IP地址



To get the local IP address

string sHostName = Dns.GetHostName (); 
IPHostEntry ipE = Dns.GetHostByName (sHostName); 
IPAddress [] IpA = ipE.AddressList; 
for (int i = 0; i < IpA.Length; i++) 
{ 
    Console.WriteLine ("IP Address {0}: {1} ", i, IpA[i].ToString ()); 
}


这篇关于asp.net中的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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