Uri 클래스

정의

URI(Uniform Resource Identifier) 값을 나타내는 개체를 정의하고 구성 요소로 구문 분석합니다. Uri 개체는 웹 브라우저 시나리오에만 국한되지 않는 다른 많은 Windows 런타임 API에서 사용됩니다.

.Net .NET을 사용하여 프로그래밍할 때 이 형식은 숨겨지고 개발자는 System.Uri를 사용해야 합니다. 설명 부분을 참조하세요.

public ref class Uri sealed : IStringable
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.IUriRuntimeClassFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Uri final : IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.IUriRuntimeClassFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class Uri final : IStringable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.IUriRuntimeClassFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Uri : IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.IUriRuntimeClassFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class Uri : IStringable
function Uri(baseUri, relativeUri)
Public NotInheritable Class Uri
Implements IStringable
상속
Object Platform::Object IInspectable Uri
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

이 예제에서는 http 프로토콜을 사용하여 웹 사이트에 액세스하는 URI(Uniform Resource Identifier)를 나타내는 Uri 개체를 만듭니다.

// The URI string
var uriToLaunch = "http://www.bing.com";

// Create a Uri object from the URI string
var uri = new Windows.Foundation.Uri(uriToLaunch);
// The URI string.
std::wstring uriToLaunch{ L"http://www.bing.com" };

// Create a Uri object from the URI string.
Windows::Foundation::Uri uri{ uriToLaunch };
// The URI string
var uriToLaunch = L"http://www.bing.com";

// Create a Uri object from the URI string
auto uri = ref new Windows::Foundation::Uri(uriToLaunch);

이 예제에서는 ms-appx 프로토콜을 사용하여 앱 패키지의 이미지 파일에 액세스하는 Uri를 만듭니다.

// The URI string
var uriImage = "ms-appx:///images/SecondaryTileDefault-sdk.png";

// Create a Uri object from the URI string
var uri = new Windows.Foundation.Uri(uriImage);
// The URI string.
std::wstring uriImage{ L"ms-appx:///images/SecondaryTileDefault-sdk.png" };

// Create a Uri object from the URI string.
Windows::Foundation::Uri uri{ uriImage };
// The URI string
var uriImage = ;

// Create a Uri object from the URI string
auto uri = ref new Windows::Foundation::Uri(uriImage);

이 예제에서는 ms-appdata 프로토콜을 사용하여 앱에 대한 로컬 앱 데이터 저장소의 파일에 액세스하는 Uri를 만듭니다.

// The URI string
var uriFile = "ms-appdata:///local/file.ext";

// Create a Uri object from the URI string
var uri = new Windows.Foundation.Uri(uriFile);
// The URI string.
std::wstring uriFile{ L"ms-appdata:///local/file.ext" };

// Create a Uri object from the URI string.
Windows::Foundation::Uri uri{ uriFile };
// The URI string
var uriFile = "ms-appdata:///local/file.ext";

// Create a Uri object from the URI string
auto uri = ref new Windows::Foundation::Uri(uriFile);

설명

중요

.NET으로 프로그래밍할 때 이 클래스는 숨겨지며 개발자는 RFC 3987 규칙을 사용하여 URI(Uniform Resource Identifier)를 인코딩하고 디코딩하는 System.Uri 클래스를 사용해야 합니다. Windows.Foundation.Uri 클래스는 스키마가 Windows 파일 경로(예: ms-appx:)를 참조하는 URI(Uniform Resource Identifier)에서 ASCII가 아닌 문자를 백분율로 인코딩하지 않습니다. 또한 Windows.Foundation.Uri는 사용자의 현재 코드 페이지를 사용하여 백분율 인코딩을 해석합니다.

System.Uri의 사용 가능한 멤버는 Windows.Foundation.Uri의 멤버와 비슷하지만 다르며 이 항목에 설명된 몇 가지 기본 동작은 다릅니다. 인코딩 차이점 및 사용 가능한 멤버에 대한 자세한 내용은 System.Uri (특히 설명)를 참조하세요.

다음은 URI(Uniform Resource Identifier) 예제 부분의 분석입니다.

scheme://username:password@host:port/path.확장?쿼리#조각

예를 들면 다음과 같습니다.

http://msdn.microsoft.com/library/windows/apps/windows.foundation.uri.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1

이 예제에서는 다음이 적용됩니다.

  • scheme is http
  • 호스트 가 입니다. msdn.microsoft.com
  • domain is microsoft.com ( 호스트의 하위 집합)
  • 확장 이 입니다. aspx
  • 쿼리 는 다음과 입니다. cs-save-lang=1&cs-lang=cpp
  • 조각 은 입니다. code-snippet-1

참고

호스트 앞의 username:password@는 주로 FTP(파일 전송 프로토콜) URI(Uniform Resource Identifier)와 관련이 있습니다. FTP(파일 전송 프로토콜) URI는 Windows 런타임 지원이 제한되어 있습니다. "백그라운드에서 데이터 전송"(HTML 또는 XAML)을 참조하세요.

중요

Windows 런타임 앱에서 가능한 모든 스키마를 사용할 수 있는 것은 아닙니다. 특히 파일: 스키마가 차단됩니다. Windows 런타임 앱에서 지원하지 않는 체계를 사용하는 Uri 개체를 만들 수 있으며, 개체를 만들 때가 아니라 API 호출에 대한 입력 값으로 해당 Uri를 적용하려고 하면 차단됩니다.

Windows 런타임 앱과 관련된 URI 체계

Windows 런타임 Windows 런타임 앱에 고유한 여러 체계가 있으며 앱의 일부인 자산을 참조합니다. 일반적으로 이러한 스키마는 파일 대신 사용할 수 있습니다. 스키마는 패키지된 파일 및 앱 패키지의 일부로 포함된 기타 자산 또는 설치된 앱과 연결된 자산을 참조합니다.

이러한 각 스키마는 다른 스키마(예: 쿼리조각)를 위한 URI(Uniform Resource Identifier)의 많은 구성 요소 부분을 무시합니다. 또한 특정 구성 요소는 명시적으로 허용되지 않으며 이러한 스키마를 사용하는 Uri 값이 잘못된 입력으로 처리되도록 합니다(예: ms-appx의 UserNamePassword 값: Uri 체계는 Uri를 무효화함). 자세한 내용은 URI 체계를 참조하세요.

대부분의 경우 현재 앱을 권한으로 사용하여 현재 앱의 루트를 참조하는 세 개의 슬래시(예: ms-appx:///page.html)와 함께 이러한 체계를 사용합니다. 두 슬래시가 있는 사용은 가능하지만 권한 이름을 명시적으로 지정해야 할 수 있습니다. 두 슬래시가 있는 사용은 패키지 종속성을 기관으로 참조하거나 앱 내의 상대 위치를 참조할 수 있습니다. 자세한 내용은 URI 체계를 참조하세요.

절대 및 상대 URI

코드 수준에서 Windows 런타임 상대 URI(Uniform Resource Identifier)를 지원하지 않습니다. 만드는 모든 Uri 개체는 절대 URI(Uniform Resource Identifier)를 나타내야 합니다. 이전 섹션에 나열된 체계는 실제로 절대 URI(Uniform Resource Identifier)입니다. 호스트 및 권한은 각 스키마에 대해 암시적이며 경로의 나머지 부분은 해당 기관에서 평가되기 때문입니다.

URI 스키마로 앱 시작

URI 값의 URI(Uniform Resource Identifier) 체계를 사용하여 특정 스키마와 연결된 다른 앱을 시작할 수 있습니다. 자세한 내용은 URI에 대한 기본 앱 시작을 참조하세요.

생성자

Uri(String)

지정된 URI (Uniform Resource Identifier) 문자열에서 새 Uri 개체를 초기화합니다. Uri를 초기화하면 문자열도 구문 분석되고 URI(Uniform Resource Identifier) 구성 요소를 나타내는 Uri 속성이 채워집니다.

Uri(String, String)

기본 URI(Uniform Resource Identifier)와 상대 URI (Uniform Resource Identifier)를 결합하여 새 URI를 초기화합니다. 또한 Uri를 초기화하면 결합된 문자열이 구문 분석되고 URI(Uniform Resource Identifier) 구성 요소를 나타내는 Uri 속성이 채워집니다.

속성

AbsoluteCanonicalUri

현재 URI의 정식 RFC 규격 표현을 가져옵니다.

AbsoluteUri

정식이 아닌 전체 URI를 가져옵니다( Windows.Foundation.Uri 인코딩 동작에 따라 실제로 IRI일 수 있으므로 정식이 아닌 URI입니다. 설명 참조).

DisplayIri

현재 URI를 구성하는 디코딩된 유니코드 문자를 가져옵니다.

DisplayUri

표시 목적으로 사용할 수 있는 URI(Uniform Resource Identifier)의 표현을 가져옵니다.

Domain

URI(Uniform Resource Identifier)에서 최상위 도메인을 포함한 도메인 이름 구성 요소를 가져옵니다.

Extension

Uri에서 참조되는 리소스의 파일 이름 확장명을 가져옵니다.

Fragment

조각 표식 자체를 포함하여 조각 표식(#) 다음에 있는 텍스트를 가져옵니다.

Host

정규화된 도메인 이름을 가져옵니다.

Password

URI instance 저장된 URI(Uniform Resource Identifier)의 암호 구성 요소를 가져옵니다.

Path

URI instance 저장된 URI(Uniform Resource Identifier)의 경로 및 리소스 이름 구성 요소를 가져옵니다.

Port

URI instance 저장된 URI(Uniform Resource Identifier)의 포트 번호 구성 요소를 가져옵니다.

Query

URI instance 저장된 URI(Uniform Resource Identifier)의 쿼리 문자열 구성 요소를 가져옵니다.

QueryParsed

구문 분석된 URI(Uniform Resource Identifier) 쿼리 문자열을 가져옵니다.

RawUri

인코딩을 적용하지 않고 구문 분석하기 전에 이 Uri 개체를 생성하는 데 사용되는 원래 URI (Uniform Resource Identifier) 문자열 전체를 가져옵니다.

SchemeName

URI에 저장된 URI(Uniform Resource Identifier)의 프로토콜 체계 이름 구성 요소를 가져옵니다instance

Suspicious

구문 분석에서 URI(Uniform Resource Identifier)가 올바른 형식이 아닌지 여부를 나타내는 값을 가져옵니다.

UserName

이 URI instance 저장된 URI(Uniform Resource Identifier)의 사용자 이름 구성 요소를 가져옵니다.

메서드

CombineUri(String)

지정된 URI(Uniform Resource Identifier)를 현재 Uri에 추가합니다.

Equals(Uri)

지정된 Uri 개체가 현재 Uri 개체와 같은지 여부를 확인합니다.

EscapeComponent(String)

URI(Uniform Resource Identifier) 문자열을 이스케이프된 표현으로 변환합니다.

ToString()

현재 Uri에 대한 정식 문자열 표현을 가져옵니다.

UnescapeComponent(String)

이스케이프 시퀀스를 이스케이프되지 않은 표현으로 대체하여 지정된 문자열을 변환합니다.

적용 대상

추가 정보