Sdílet prostřednictvím


Uri.OriginalString Vlastnost

Definice

Získá původní řetězec identifikátoru URI, který byl předán konstruktoru Uri .

public:
 property System::String ^ OriginalString { System::String ^ get(); };
public string OriginalString { get; }
member this.OriginalString : string
Public ReadOnly Property OriginalString As String

Hodnota vlastnosti

Přesný identifikátor URI zadaný při vytváření této instance; v opačném případě . Empty

Příklady

Následující příklad vytvoří novou Uri instanci z řetězce. Ukazuje rozdíl mezi hodnotou vrácenou OriginalStringz , která vrátí řetězec, který byl předán konstruktoru, a z volání ToString, který vrátí kanonický tvar řetězce.

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

Poznámky

Pokud identifikátor URI zadaný konstruktorem obsahoval úvodní nebo koncové mezery, zachovají se tyto mezery.

Hodnota vrácená touto vlastností se liší od ToString a AbsoluteUri. ToString vrátí kanonicky unescaped tvar identifikátoru URI. AbsoluteUri vrátí kanonický řídicí tvar identifikátoru URI.

Pokud je povolená podpora International Resource Identifier (IRI) a Internationalized Domain Name (IDN), OriginalString vrátí původní nenormalizovaný řetězec s názvem hostitele Punycode, pokud byl použit k inicializaci Uri instance. Názvy v Punycode obsahují pouze znaky ASCII a vždy začínají prefixem xn--.

Další informace o podpoře IRI naleznete v části Poznámky pro Uri třídu.

Uri Při serializaci objektu OriginalString se nezachová. Proces serializace používá plně řídicí a kanonický AbsoluteUri vlastnost při serializaci. Uri U adresy IPv6, která obsahuje IPv6 adresu a ID oboru, jsou zahrnuty do serializovaného Uri objektu.

Platí pro