/// <summary> /// Checks for IP address or well known hostnames that map to the computer. /// </summary> /// <param name="hostname">The hostname.</param> /// <returns>The hostname to use for URL filtering.</returns> protected string NormalizeHostname(string hostname) { string computerName = Utils.GetHostName(); // substitute the computer name for localhost if localhost used by client. if (Utils.AreDomainsEqual(hostname, "localhost")) { return(computerName.ToUpper()); } // check if client is using an ip address. IPAddress address = null; if (System.Net.IPAddress.TryParse(hostname, out address)) { if (System.Net.IPAddress.IsLoopback(address)) { return(computerName.ToUpper()); } // substitute the computer name for any local IP if an IP is used by client. IPAddress[] addresses = Utils.GetHostAddresses(Utils.GetHostName()); for (int ii = 0; ii < addresses.Length; ii++) { if (addresses[ii].Equals(address)) { return(computerName.ToUpper()); } } // not a localhost IP address. return(hostname.ToUpper()); } // return normalized hostname. return(hostname.ToUpper()); }