How to get the hostname or IP address of the server

HttpContext.Current.Server.MachineName

HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]

The first one should return the name of the machine, the second returns the local ip address.Note that name of the machine could be different than host, since your site could be using host headers.