Uri.OriginalString Uri.OriginalString Uri.OriginalString Uri.OriginalString Property

Definição

Obtém a cadeia de caracteres do URI original que foi passada para o construtor Uri.Gets the original URI string that was passed to the Uri constructor.

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

Valor da propriedade

Um String que contém o URI exato especificado quando esta instância foi construída; caso contrário, Empty.A String containing the exact URI specified when this instance was constructed; otherwise, Empty.

Exemplos

O exemplo a seguir cria uma nova instância Uri a partir de uma cadeia de caracteres.The following example creates a new Uri instance from a string. Ele ilustra a diferença entre o valor retornado de OriginalString, que retorna a cadeia de caracteres que foi passada para o construtor e de uma chamada para ToString, que retorna a forma canônica da cadeia de caracteres.It illustrates the difference between the value returned from OriginalString, which returns the string that was passed to the constructor, and from a call to ToString, which returns the canonical form of the string.

// Create a new Uri from a string address.
Uri^ uriAddress = gcnew 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 orginal 
// string that was passed to the constructor.
// The following outputs "http://www.contoso.com/thick and thin.htm".
Console::WriteLine( uriAddress );

// The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm".
Console::WriteLine( uriAddress->OriginalString );
// 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 orginal 
// 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.
    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 orginal 
    ' 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

Comentários

Se o URI especificado para o Construtor contiver espaços à esquerda ou à direita, esses espaços serão preservados.If the URI specified to the constructor contained leading or trailing spaces, these spaces are preserved.

O valor retornado por essa propriedade difere de ToString e AbsoluteUri.The value returned by this property differs from ToString and AbsoluteUri. ToString retorna a forma canônica sem escape do URI.ToString returns the canonically unescaped form of the URI. AbsoluteUri retorna a forma canônica de escape do URI.AbsoluteUri returns the canonically escaped form of the URI.

Quando o IRI (identificador de recurso internacional) e o suporte a IDN (nome de domínio internacionalizado) estiverem habilitados, OriginalString retornará a cadeia de caracteres não normalizada original com o nome de host Punycode se um tiver sido usado para inicializar a instância de Uri.When International Resource Identifier (IRI) and Internationalized Domain Name (IDN) support are enabled, OriginalString returns the original non normalized string with Punycode host name if one was used to initialize the Uri instance. Os nomes Punycode contêm apenas caracteres ASCII e sempre começam com o prefixo xn--.Punycode names contain only ASCII characters and always start with the xn-- prefix.

Para obter mais informações sobre o suporte IRI, consulte a seção Comentários da classe Uri.For more information on IRI support, see the Remarks section for the Uri class.

Quando um objeto Uri é serializado, o OriginalString não é preservado.When a Uri object is serialized, the OriginalString is not preserved. O processo de serialização usa a propriedade AbsoluteUri de escape completo e canônica ao serializar.The serialization process uses the fully escaped and canonicalized AbsoluteUri property when serializing. Para um Uri que contém um endereço IPv6, o endereço IPv6 e a ID do escopo são incluídos no objeto serializado Uri.For a Uri that contains an IPv6 address, the IPv6 address and the scope ID are included in the serialized Uri object.

Aplica-se a