How do I get the computer name in .NET

  • System.Environment.MachineName from a console or WinForms app.
  • HttpContext.Current.Server.MachineName from a web app
  • System.Net.Dns.GetHostName() to get the FQDN

See How to find FQDN of local machine in C#/.NET ? if the last doesn’t give you the FQDN and you need it.

See details about Difference between SystemInformation.ComputerName, Environment.MachineName, and Net.Dns.GetHostName

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)