如何获取IP地址 [英] How to Get IP Address
本文介绍了如何获取IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何获取IP地址.
请帮帮我...:((
I want to know how to get IP Address.
Please Help me... :((
推荐答案
查找IP地址
您可以使用此代码
首先全部包含 System.Net 命名空间,然后编写给定的代码
To Find IP Address
you can use this code
first up all include System.Net namespace and then write the given code
string str = Environment.MachineName.ToString(); // MachineName use to get the name of your System
IPHostEntry ipe = Dns.GetHostByName(str); // IPHostEntry Provide a Contaner Class for internet host address
Console.WriteLine("Your IP address is : ");
for (int i = 0; i < ipe.AddressList.Length; i++)
{
Console.WriteLine(ipe.AddressList[i]);
}
这里是一个示例:
http://netomatix.com/MachineIp.aspx
Here''s an example:
http://netomatix.com/MachineIp.aspx
在asp.net中,您可以通过它获取IP地址->
字符串ip = Request.Params ["REMOTE_ADDR"].ToString();
In asp.net you can get the ip address by it ->
string ip = Request.Params["REMOTE_ADDR"].ToString();
这篇关于如何获取IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文