如何在ASP.NET中获取我的计算机名称? [英] How to get my computer name in ASP.NET?
本文介绍了如何在ASP.NET中获取我的计算机名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在ASP.NET中获取我的计算机名称?
我正在使用此代码,但在网站上显示我的计算机服务器。
每个客户端显示计算机名称时我想要的。
Hi,
How to get my computer name in ASP.NET?
I am using this code but show my computer server on website.
I am want when show computer name per client.
System.Environment.MachineName
or
UserHostname
推荐答案
检查以下文章
返回基础 - 在ASP.NET中获取客户端计算机名称 [ ^ ]
public string GetComputerName(string clientIP)
{
try
{
var hostEntry = Dns.GetHostEntry(clientIP);
return hostEntry.HostName;
}
catch (Exception ex)
{
return string.Empty;
}
}
string ComputerName=GetName();
public string GetName()
{
string netBiosName = System.Environment.MachineName;
string dnsName = System.Net.Dns.GetHostName();
return dnsName;
}
这篇关于如何在ASP.NET中获取我的计算机名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文