My company has an ASP.NET web app that runs on a web farm that's load balanced by Enterprise Foundry ServerIron XL 8 hardware. For debugging purposes, we've got a page that just reports what server it's running on. Currently, we manually copy a different version of this page to each server, and hardcode the name of that server (e.g. www1, www2, or www3). What I'd like instead is to find a way for the app to determine this information itself, so we don't have to do this manual step, outside of the code itself, but I can't find any way to accomplish this.
So the question is: how can an ASP.NET app be made aware of where it's actually running?
You can do this via IIS itself.
Find the web application. In the app's main config page (features view), under IIS
section you'd find HTTP Response Headers
. This feature enables you to add/remove headers which need to be sent along with every response of that application.
However, you'd need tools like fiddler to be able to inspect such data.
Another option is a custom server control or user control, placed anywhere within a page which will output that information during it Render phase (as html comment). You can get using System.Environment class.
var mc_name = System.Environment.MachineName;