How to get the computer name in C#?
To get computer name in C# you must use the following depending on the environment you have.1) from a console or WinForms app.
string computerName = System.Environment.MachineName;
2) from a web app
string computerName = HttpContext.Current.Server.MachineName;
3) to get the FQDN
string computerName = System.Net.Dns.GetHostName();