Can I get the webServer's name when a host header is set (IIS, asp.Net)
-
18-09-2019 - |
Question
Is it possible to find what the Web Server's name is when the host header is set to something else in an asp.net web app? Environment is a company intranet, Windows 2003 server (IIS 6).
e.g. the host header may be set to myApp.company.com and the servers name might be webAppServer1.company.com or webAppServer2.company.com
Using the Server Variable "SERVER_NAME" just returns the host header...
Thanks heaps!
Solution
Try:
string host = Environment.MachineName;
OTHER TIPS
Also, this I presume accesses the same information as Wim Hollebrandse's suggestion:
My.Computer.Name
Yet another option is using: Server.MachineName
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow