Uri.OriginalString 속성

정의

Uri 생성자에 전달된 원래 URI 문자열을 가져옵니다.

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

속성 값

이 instance 생성될 때 지정된 정확한 URI입니다. 그렇지 않으면 Empty입니다.

예제

다음 예제에서는 문자열에서 새 Uri instance 만듭니다. 생성자에 전달된 문자열을 반환하는 에서 OriginalString반환된 값과 문자열의 정식 형식을 반환하는 에 대한 ToString호출 간의 차이를 보여 줍니다.

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

설명

생성자에 지정된 URI에 선행 또는 후행 공백이 포함된 경우 이러한 공백이 유지됩니다.

이 속성에서 반환되는 값은 ToString 및 와 AbsoluteUri다릅니다. ToString 는 URI의 대소식으로 캡슐화되지 않은 형식을 반환합니다. AbsoluteUri 는 URI의 정식 이스케이프 형식을 반환합니다.

IRI(International Resource Identifier) 및 IDN(Internationalized Domain Name) 지원을 사용하도록 설정한 OriginalString 경우 은 instance 초기화하는 Uri 데 사용된 경우 Punycode 호스트 이름을 사용하여 정규화되지 않은 원래 문자열을 반환합니다. Punycode 이름에는 ASCII 문자만 사용되며 항상 xn-- 접두사로 시작합니다.

IRI 지원에 대한 자세한 내용은 클래스에 대한 설명 섹션을 Uri 참조하세요.

개체가 Uri 직렬화되면 가 OriginalString 유지되지 않습니다. serialization 프로세스는 직렬화할 때 완전히 이스케이프되고 정식화된 AbsoluteUri 속성을 사용합니다. Uri IPv6 주소가 포함된 의 경우 IPv6 주소와 scope ID가 직렬화된 Uri 개체에 포함됩니다.

적용 대상