BVNetwork.NotFound.Core.Custom404Handler.IsLocalhost C# (CSharp) Method

IsLocalhost() private static method

Determines whether the current request is on localhost.
private static IsLocalhost ( ) : bool
return bool
        private static bool IsLocalhost()
        {
            bool localHost = false;
            try
            {
                System.Net.IPAddress address = System.Net.IPAddress.Parse(HttpContext.Current.Request.UserHostAddress);
                Debug.WriteLine("IP Address of user: " + address, "404Handler");

                IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
                Debug.WriteLine("Host Entry of local computer: " + host.HostName, "404Handler");
                localHost = address.Equals(IPAddress.Loopback) || (Array.IndexOf(host.AddressList, address) >= 0);
            }
            catch
            {
                // localhost is false
            }
            return localHost;
        }