Home >Backend Development >C++ >How to Get the Computer Name and FQDN in .NET?
Getting the Computer Name in .NET
Retrieving the computer name is a common task in .NET applications. There are several methods available to accomplish this, depending on the type of application you are developing.
Console or WinForms app:
string computerName = System.Environment.MachineName;
Web app:
string computerName = HttpContext.Current.Server.MachineName;
Getting the Fully Qualified Domain Name (FQDN):
string fqdn = System.Net.Dns.GetHostName();
If System.Net.Dns.GetHostName() does not provide the FQDN and you require it, refer to this resource: [How to find FQDN of local machine in C#/.NET?](https://stackoverflow.com/questions/854213/how-to-find-fqdn-of-local-machine-in-c-net)
For additional insights, review this article: [Difference between SystemInformation.ComputerName, Environment.MachineName, and Net.Dns.GetHostName](https://codereview.stackexchange.com/questions/37366/difference-between-systeminformation-computername-environment-machinenam).
The above is the detailed content of How to Get the Computer Name and FQDN in .NET?. For more information, please follow other related articles on the PHP Chinese website!