日期:2014-05-18  浏览次数:20398 次

进来就有分。。。
。net中。得到客户端的IP是:
string ClientIp = System.Web.HttpContext.Current.Request.UserHostAddress;
那得到对方完整的计算机名称改怎么写啊?

------解决方案--------------------
http://www.pc51.net/wangluobiancheng/net/2007-01-21/5058.html

MAY BE这样,没试过,呵呵
------解决方案--------------------
哦,是客户端的...弄错了.

HTTP协议里没有机器名,我想你用HTTP相关的方法取不到
------解决方案--------------------
你找找js吧
------解决方案--------------------
using System; 
using System.Net; 

namespace GetIpAndName 

class Class1 

[STAThread] 
static void Main(string[] args) 

//得到主机名 
string name = Dns.GetHostName(); 
Console.WriteLine("主机名字:{0}",name); 
IPHostEntry me = Dns.GetHostByName(name); 
//输出得到的IP 
foreach (IPAddress ip in me.AddressList) 

Console.WriteLine("IP 地址:{0}",ip.ToString()); 

Console.Read(); 

}
------解决方案--------------------
jf

------解决方案--------------------
jf
------解决方案--------------------
jf
------解决方案--------------------
/// <summary>
/// 得到当前完整主机头
/// </summary>
/// <returns></returns>
public static string GetCurrentFullHost()
{
HttpRequest request = System.Web.HttpContext.Current.Request;
if (!request.Url.IsDefaultPort)
{
return string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString());
}
return request.Url.Host;
}
------解决方案--------------------
楼主的问题,我帮忙顶
------解决方案--------------------
接分
------解决方案--------------------
学习 并jf
------解决方案--------------------
难是很实现啊,否则哪还有隐私可言。
------解决方案--------------------
jf