Uri.IsBaseOf(Uri) Methode

Definition

Bestimmt, ob die aktuelle Uri Instanz eine Basis der angegebenen Uri Instanz ist.

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

Parameter

uri
Uri

Der angegebene zu testde URI.

Gibt zurück

true wenn die aktuelle Uri Instanz eine Basis von uri; andernfalls false.

Ausnahmen

uri ist null.

Beispiele

In diesem Beispiel wird eine Uri Instanz erstellt, die eine Basisinstanz Uri darstellt. Anschließend wird eine zweite Uri Instanz aus einer Zeichenfolge erstellt. Sie ruft IsBaseOf auf, um zu bestimmen, ob die Basisinstanz die Basis der zweiten Instanz ist. Das Ergebnis wird in die Konsole geschrieben.

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

Hinweise

IsBaseOf wird verwendet, um die aktuelle Uri Instanz mit einem angegebenen Uri zu vergleichen, um zu bestimmen, ob dieser URI eine Basis für den angegebenen Uriist. Beim Vergleichen von zwei Uri Objekten zur Ermittlung einer Basisbeziehung werden die Benutzerinformationen (UserInfo) nicht ausgewertet. Beim Vergleichen von zwei URIs (uri1 und uri2) ist uri1 die Basis von uri2, wenn Sie alles in uri1 und uri2 nach dem letzten Schrägstrich (/) ignorieren, beginnt uri2 mit genau uri1. Die http://host/path/path/file?query folgende Tabelle zeigt als Basis-URI an, ob es sich um eine Basis für andere URIs handelt.

URI http://host/path/path/file?query ist Basis von
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 Nein
http://host/path/path?query Nein
http://host/path/path#Fragment Nein
http://host/path/path2/ Nein
://host/path/path2/MoreDir Nein
http://host/path/File Nein

Gilt für: