0

I am building a web application and I want to be able to get the name of the server that the application is running on.

I've seen a few examples that suggest using System.Environment.MachineName but it wasn't clear to me if this would retrieve the server name or the computer name of the user accessing the application. Can someone clear this up for me?

Thanks

jimminybob
  • 1,292
  • 1
  • 24
  • 57
  • What's an example of the sort of name you want returned? The Windows machine name? Or the DNS host name? Or something else? – Kirk Woll Dec 18 '14 at 15:05
  • Its the machine name i'm after. The one you can see if you go to Control Panel > System > Computer name – jimminybob Dec 18 '14 at 15:10
  • 2
    Your web code runs on the server, so it returns the name of the server the web application is running on. – Rick S Dec 18 '14 at 15:10
  • Your code should work fine. Please see http://msdn.microsoft.com/en-us/library/system.environment.machinename%28v=vs.110%29.aspx .It gets the NetBIOS name. It also is confirmed here: http://stackoverflow.com/questions/662282/how-do-i-get-the-local-machine-name .This actually does the same thing as typing hostname to the command prompt. – Hozikimaru Dec 18 '14 at 16:59

0 Answers0