Uri.IsBaseOf(Uri) 메서드

정의

현재 Uri 인스턴스가 지정된 Uri 인스턴스의 기반인지 여부를 확인합니다.

public:
 bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf(Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean

매개 변수

uri
Uri

테스트할 지정된 URI입니다.

반품

현재 인스턴스가 기본 이면 그렇지 않으면 .

예외

urinull입니다.

예제

이 예제에서는 기본 Uri 인스턴스를 Uri 나타내는 인스턴스를 만듭니다. 그런 다음 문자열에서 두 번째 Uri 인스턴스를 만듭니다. 기본 인스턴스가 두 번째 인스턴스의 기반인지 여부를 확인하기 위해 호출 IsBaseOf 합니다. 결과는 콘솔에 기록됩니다.

// Create a base Uri.
Uri baseUri = new Uri("http://www.contoso.com/");

// Create a new Uri from a string.
Uri uriAddress = new Uri("http://www.contoso.com/index.htm?date=today");

// Determine whether BaseUri is a base of UriAddress.
if (baseUri.IsBaseOf(uriAddress))
    Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress);
// Create a base Uri.
let baseUri = Uri "http://www.contoso.com/"

// Create a new Uri from a string.
let uriAddress = Uri "http://www.contoso.com/index.htm?date=today"

// Determine whether BaseUri is a base of UriAddress.
if baseUri.IsBaseOf uriAddress then
    printfn $"{baseUri} is the base of {uriAddress}"
' Create a base Uri.
Dim baseUri As New Uri("http://www.contoso.com/")

' Create a new Uri from a string.
Dim uriAddress As New Uri("http://www.contoso.com/index.htm?date=today")

' Determine whether BaseUri is a base of UriAddress.  
If baseUri.IsBaseOf(uriAddress) Then
    Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress)
End If

설명

IsBaseOf 는 현재 Uri 인스턴스를 지정된 Uri 인스턴스와 비교하여 이 URI가 지정된 URI의 기반 Uri인지 여부를 확인하는 데 사용됩니다. 두 Uri 개체를 비교하여 기본 관계를 결정할 때 사용자 정보(UserInfo)는 평가되지 않습니다. 두 URI(uri1 및 uri2)를 비교할 때 uri1은 마지막 슬래시(/) 후 uri1 및 uri2의 모든 항목을 무시하면 uri2의 기준이 됩니다. uri2는 정확히 uri1로 시작합니다. 다음 표에서는 기본 URI로 사용하여 http://host/path/path/file?query 다른 URI의 기반인지 여부를 보여 줍니다.

URI 의 기준입니다
http://host/path/path/file/
http://host/path/path/#fragment
http://host/path/path/MoreDir/"
http://host/path/path/OtherFile?Query
http://host/path/path/
http://host/path/path/file
http://host/path/path no
http://host/path/path?query no
http://host/path/path#Fragment no
http://host/path/path2/ no
://host/path/path2/MoreDir no
http://host/path/File no

적용 대상