Uri.OriginalString Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de oorspronkelijke URI-tekenreeks op die is doorgegeven aan de Uri constructor.
public:
property System::String ^ OriginalString { System::String ^ get(); };
public string OriginalString { get; }
member this.OriginalString : string
Public ReadOnly Property OriginalString As String
Waarde van eigenschap
De exacte URI die is opgegeven toen dit exemplaar werd gebouwd; anders, Empty.
Voorbeelden
In het volgende voorbeeld wordt een nieuw Uri exemplaar gemaakt op basis van een tekenreeks. Het illustreert het verschil tussen de waarde die wordt geretourneerd van OriginalString, waarmee de tekenreeks wordt geretourneerd die is doorgegeven aan de constructor, en van een aanroep naar ToString, die de canonieke vorm van de tekenreeks retourneert.
// Create a new Uri from a string address.
Uri uriAddress = new Uri("HTTP://www.ConToso.com:80//thick%20and%20thin.htm");
// Write the new Uri to the console and note the difference in the two values.
// ToString() gives the canonical version. OriginalString gives the original
// string that was passed to the constructor.
// The following outputs "http://www.contoso.com//thick and thin.htm".
Console.WriteLine(uriAddress.ToString());
// The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm".
Console.WriteLine(uriAddress.OriginalString);
// Create a new Uri from a string address.
let uriAddress = Uri "HTTP://www.ConToso.com:80//thick%20and%20thin.htm"
// Write the new Uri to the console and note the difference in the two values.
// ToString() gives the canonical version. OriginalString gives the original
// string that was passed to the constructor.
// The following outputs "http://www.contoso.com//thick and thin.htm".
printfn $"{uriAddress.ToString()}"
// The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm".
printfn $"{uriAddress.OriginalString}"
' Create a new Uri from a string address.
Dim uriAddress As New Uri("HTTP://www.ConToso.com:80//thick%20and%20thin.htm")
' Write the new Uri to the console and note the difference in the two values.
' ToString() gives the canonical version. OriginalString gives the original
' string that was passed to the constructor.
' The following outputs "http://www.contoso.com//thick and thin.htm".
Console.WriteLine(uriAddress.ToString())
' The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm".
Console.WriteLine(uriAddress.OriginalString)
End Sub
Opmerkingen
Als de URI die aan de constructor is opgegeven, voorloop- of volgspaties bevat, blijven deze spaties behouden.
De waarde die door deze eigenschap wordt geretourneerd, verschilt van ToString en AbsoluteUri. ToString retourneert de canonieke ongezichtige vorm van de URI. AbsoluteUri retourneert de canonieke escape-vorm van de URI.
Wanneer ondersteuning voor International Resource Identifier (IRI) en Internationalized Domain Name (IDN) is ingeschakeld, OriginalString wordt de oorspronkelijke niet-genormaliseerde tekenreeks geretourneerd met de Punycode-hostnaam als deze is gebruikt om het Uri exemplaar te initialiseren. Punycodenamen bevatten alleen ASCII-tekens en beginnen altijd met het xn-voorvoegsel.
Zie de sectie Opmerkingen voor de Uri klas voor meer informatie over IRI-ondersteuning.
Wanneer een Uri object wordt geserialiseerd, blijft het OriginalString niet behouden. Het serialisatieproces maakt gebruik van de volledig ontsnapte en canonieke AbsoluteUri eigenschap bij het serialiseren. Voor een Uri adres dat een IPv6-adres bevat, worden het IPv6-adres en de bereik-id opgenomen in het geserialiseerde Uri object.