Uri.IsLoopback 속성

정의

지정한 Uri가 로컬 호스트를 참조하는지 여부를 나타내는 값을 가져옵니다.Gets a value that indicates whether the specified Uri references the local host.

public:
 property bool IsLoopback { bool get(); };
public bool IsLoopback { get; }
member this.IsLoopback : bool
Public ReadOnly Property IsLoopback As Boolean

속성 값

Boolean

<see langword="true" /> if this <see cref="T:System.Uri" /> references the local host; otherwise, <see langword="false" />.

예외

이 인스턴스가 상대 URI를 나타내고 이 속성이 절대 URI에만 유효한 경우This instance represents a relative URI, and this property is valid only for absolute URIs.

예제

다음 예에서는 인스턴스를 만들고 Uri 로컬 호스트를 참조 하는지 여부를 확인 합니다.The following example creates a Uri instance and determines whether it references a local host.

Uri^ uriAddress2 = gcnew Uri( "file://server/filename.ext" );
Console::WriteLine( uriAddress2->LocalPath );
Console::WriteLine( "Uri {0} a UNC path", uriAddress2->IsUnc ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a local host", uriAddress2->IsLoopback ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a file", uriAddress2->IsFile ? (String^)"is" : "is not" );
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Uri uriAddress2 =  new Uri("file://server/filename.ext");
Console.WriteLine(uriAddress2.LocalPath);
Console.WriteLine("Uri {0} a UNC path", uriAddress2.IsUnc ? "is" : "is not");
Console.WriteLine("Uri {0} a local host", uriAddress2.IsLoopback ? "is" : "is not");
Console.WriteLine("Uri {0} a file", uriAddress2.IsFile ? "is" : "is not");
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Dim uriAddress2 As New Uri("file://server/filename.ext")
Console.WriteLine(uriAddress2.LocalPath)
Console.WriteLine("Uri {0} a UNC path", IIf(uriAddress2.IsUnc, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a local host", IIf(uriAddress2.IsLoopback, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a file", IIf(uriAddress2.IsFile, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
' The example displays the following output:
'    \\server\filename.ext
'    Uri is a UNC path
'    Uri is not a local host
'    Uri is a file

설명

IsLoopbacktrue이 인스턴스가 만들어질 때 지정 된 uri가 127.0.0.1, 루프백 또는 localhost 이거나 uri가 호스트 정보 (예: file:///c:Dir/file.txt)를 지정 하지 않은 경우를 반환 합니다.IsLoopback returns true if the URI specified when this instance was created was 127.0.0.1, loopback, or localhost, or if the URI did not specify host information (for example, file:///c:Dir/file.txt). 다른 모든 Uri는 false 를 반환 합니다.All other URIs return false.

적용 대상