Mono Class Library: System.Uri Overview | Members

System.Uri.IsLoopback Property

Gets a bool value indicating whether the host information of the current instance is the current computer.

public bool IsLoopback { get; }

Value

true if the host of the current instance is the reserved hostname "localhost" or the loop-back IP address (127.0.0.1); otherwise, false.

Remarks

This property is read-only.

Example

The following example demonstrates the Uri.IsLoopback property.

C# Example

using System;

public class UriTest {
 public static void Main() {
 Uri myUri = new Uri("http://127.0.0.1/index.htm", true);
 Console.WriteLine("{0} is loopback? {1}", myUri.ToString(), myUri.IsLoopback);

 myUri = new Uri("http://localhost/index.htm", true);
 Console.WriteLine("{0} is loopback? {1}", myUri.ToString(), myUri.IsLoopback);

 }
}

The output is

http://127.0.0.1/index.htm is loopback? True

http://localhost/index.htm is loopback? True

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0