Uri.IsBaseOf(Uri) Methode

Definitie

Bepaalt of het huidige Uri exemplaar een basis is van het opgegeven Uri exemplaar.

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

Parameters

uri
Uri

De opgegeven URI die moet worden getest.

Retouren

trueals het huidige Uri exemplaar een basis is vanuri; anders. false

Uitzonderingen

uri is null.

Voorbeelden

In dit voorbeeld wordt een Uri exemplaar gemaakt dat een basisexemplaren Uri vertegenwoordigt. Vervolgens wordt er een tweede Uri exemplaar gemaakt op basis van een tekenreeks. Er wordt aanroepen IsBaseOf om te bepalen of het basisexemplaren de basis van het tweede exemplaar is. Het resultaat wordt naar de console geschreven.

// 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

Opmerkingen

IsBaseOf wordt gebruikt om het huidige Uri exemplaar te vergelijken met een opgegeven Uri om te bepalen of deze URI een basis is voor de opgegeven Uri. Wanneer u twee Uri objecten vergelijkt om een basisrelatie te bepalen, wordt de gebruikersgegevens (UserInfo) niet geƫvalueerd. Bij het vergelijken van twee URI's (URI1 en URI2), is URI1 de basis van URI2 als, wanneer u alles in URI1 en URI2 na de laatste slash (/) negeert, URI2 begint met exact URI1. Als http://host/path/path/file?query basis-URI wordt in de volgende tabel weergegeven of het een basis is voor andere URI's.

URI http://host/path/path/file?query is basis van
http://host/path/path/file/ Ja
http://host/path/path/#fragment Ja
http://host/path/path/MoreDir/" Ja
http://host/path/path/OtherFile?Query Ja
http://host/path/path/ Ja
http://host/path/path/file Ja
http://host/path/path nee
http://host/path/path?query nee
http://host/path/path#Fragment nee
http://host/path/path2/ nee
://host/path/path2/MoreDir nee
http://host/path/File nee

Van toepassing op