Uri 클래스

정의

URI(Uniform Resource Indentifier)의 개체 표현을 제공하며 URI 부분에 쉽게 액세스할 수 있도록 합니다.

public ref class Uri
public ref class Uri : System::Runtime::Serialization::ISerializable
public ref class Uri : ISpanFormattable, System::Runtime::Serialization::ISerializable
public ref class Uri : MarshalByRefObject, System::Runtime::Serialization::ISerializable
public class Uri
public class Uri : System.Runtime.Serialization.ISerializable
public class Uri : ISpanFormattable, System.Runtime.Serialization.ISerializable
[System.Serializable]
public class Uri : MarshalByRefObject, System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.ComponentModel.TypeConverter(typeof(System.UriTypeConverter))]
public class Uri : System.Runtime.Serialization.ISerializable
type Uri = class
type Uri = class
    interface ISerializable
type Uri = class
    interface ISpanFormattable
    interface IFormattable
    interface ISerializable
type Uri = class
    interface IFormattable
    interface ISpanFormattable
    interface ISerializable
[<System.Serializable>]
type Uri = class
    inherit MarshalByRefObject
    interface ISerializable
[<System.Serializable>]
[<System.ComponentModel.TypeConverter(typeof(System.UriTypeConverter))>]
type Uri = class
    interface ISerializable
Public Class Uri
Public Class Uri
Implements ISerializable
Public Class Uri
Implements ISerializable, ISpanFormattable
Public Class Uri
Inherits MarshalByRefObject
Implements ISerializable
상속
Uri
상속
특성
구현

예제

다음 예제에서는 클래스의 Uri instance 만들고 를 사용하여 GET 요청을 HttpClient수행합니다.

Uri^ siteUri = gcnew Uri("http://www.contoso.com/");

// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
HttpClient^ client = gcnew HttpClient;
HttpRequestMessage^ request = gcnew HttpRequestMessage(HttpMethod::Get, siteUri);
HttpResponseMessage^ response = client->Send(request);
Uri siteUri = new Uri("http://www.contoso.com/");

// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, siteUri);
HttpResponseMessage response = client.Send(request);
let siteUri = Uri "http://www.contoso.com/"

// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
use client = new HttpClient ()
use request = new HttpRequestMessage (HttpMethod.Get, siteUri)
use response = client.Send request
Dim siteUri As New Uri("http://www.contoso.com/")

' HttpClient lifecycle management best practices:
' https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
Dim client As New HttpClient()
Dim request As New HttpRequestMessage(HttpMethod.Get, siteUri)
Dim response As HttpResponseMessage = client.Send(request)

다음 코드 조각은 클래스에 있는 다양한 속성의 예제 값을 보여 있습니다.

Uri uri = new Uri("https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName");

Console.WriteLine($"AbsolutePath: {uri.AbsolutePath}");
Console.WriteLine($"AbsoluteUri: {uri.AbsoluteUri}");
Console.WriteLine($"DnsSafeHost: {uri.DnsSafeHost}");
Console.WriteLine($"Fragment: {uri.Fragment}");
Console.WriteLine($"Host: {uri.Host}");
Console.WriteLine($"HostNameType: {uri.HostNameType}");
Console.WriteLine($"IdnHost: {uri.IdnHost}");
Console.WriteLine($"IsAbsoluteUri: {uri.IsAbsoluteUri}");
Console.WriteLine($"IsDefaultPort: {uri.IsDefaultPort}");
Console.WriteLine($"IsFile: {uri.IsFile}");
Console.WriteLine($"IsLoopback: {uri.IsLoopback}");
Console.WriteLine($"IsUnc: {uri.IsUnc}");
Console.WriteLine($"LocalPath: {uri.LocalPath}");
Console.WriteLine($"OriginalString: {uri.OriginalString}");
Console.WriteLine($"PathAndQuery: {uri.PathAndQuery}");
Console.WriteLine($"Port: {uri.Port}");
Console.WriteLine($"Query: {uri.Query}");
Console.WriteLine($"Scheme: {uri.Scheme}");
Console.WriteLine($"Segments: {string.Join(", ", uri.Segments)}");
Console.WriteLine($"UserEscaped: {uri.UserEscaped}");
Console.WriteLine($"UserInfo: {uri.UserInfo}");

// AbsolutePath: /Home/Index.htm
// AbsoluteUri: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName
// DnsSafeHost: www.contoso.com
// Fragment: #FragmentName
// Host: www.contoso.com
// HostNameType: Dns
// IdnHost: www.contoso.com
// IsAbsoluteUri: True
// IsDefaultPort: False
// IsFile: False
// IsLoopback: False
// IsUnc: False
// LocalPath: /Home/Index.htm
// OriginalString: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName
// PathAndQuery: /Home/Index.htm?q1=v1&q2=v2
// Port: 80
// Query: ?q1=v1&q2=v2
// Scheme: https
// Segments: /, Home/, Index.htm
// UserEscaped: False
// UserInfo: user:password
let uri = Uri "https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"

printfn $"AbsolutePath: {uri.AbsolutePath}"
printfn $"AbsoluteUri: {uri.AbsoluteUri}"
printfn $"DnsSafeHost: {uri.DnsSafeHost}"
printfn $"Fragment: {uri.Fragment}"
printfn $"Host: {uri.Host}"
printfn $"HostNameType: {uri.HostNameType}"
printfn $"IdnHost: {uri.IdnHost}"
printfn $"IsAbsoluteUri: {uri.IsAbsoluteUri}"
printfn $"IsDefaultPort: {uri.IsDefaultPort}"
printfn $"IsFile: {uri.IsFile}"
printfn $"IsLoopback: {uri.IsLoopback}"
printfn $"IsUnc: {uri.IsUnc}"
printfn $"LocalPath: {uri.LocalPath}"
printfn $"OriginalString: {uri.OriginalString}"
printfn $"PathAndQuery: {uri.PathAndQuery}"
printfn $"Port: {uri.Port}"
printfn $"Query: {uri.Query}"
printfn $"Scheme: {uri.Scheme}"
printfn $"""Segments: {String.Join(", ", uri.Segments)}"""
printfn $"UserEscaped: {uri.UserEscaped}"
printfn $"UserInfo: {uri.UserInfo}"

// AbsolutePath: /Home/Index.htm
// AbsoluteUri: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName
// DnsSafeHost: www.contoso.com
// Fragment: #FragmentName
// Host: www.contoso.com
// HostNameType: Dns
// IdnHost: www.contoso.com
// IsAbsoluteUri: True
// IsDefaultPort: False
// IsFile: False
// IsLoopback: False
// IsUnc: False
// LocalPath: /Home/Index.htm
// OriginalString: https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName
// PathAndQuery: /Home/Index.htm?q1=v1&q2=v2
// Port: 80
// Query: ?q1=v1&q2=v2
// Scheme: https
// Segments: /, Home/, Index.htm
// UserEscaped: False
// UserInfo: user:password

설명

이 API에 대한 자세한 내용은 Uri에 대한 추가 API 설명을 참조하세요.

생성자

Uri(SerializationInfo, StreamingContext)
사용되지 않음.

UriSerializationInfo 클래스에 지정된 인스턴스에서 StreamingContext 클래스의 새 인스턴스를 초기화합니다.

Uri(String)

URI가 지정된 Uri 클래스의 새 인스턴스를 초기화합니다.

Uri(String, Boolean)
사용되지 않음.
사용되지 않음.
사용되지 않음.

문자 이스케이프를 명시적으로 제어하여 URI가 지정된 Uri 클래스의 새 인스턴스를 초기화합니다.

Uri(String, UriCreationOptions)

지정된 URI 및 추가 를 사용하여 클래스의 Uri 새 instance 초기화합니다UriCreationOptions.

Uri(String, UriKind)

URI가 지정된 Uri 클래스의 새 인스턴스를 초기화합니다. 이 생성자를 사용하면 URI 문자열이 상대 URI 또는 절대 URI인지, 아니면 결정되지 않았는지를 지정할 수 있습니다.

Uri(Uri, String)

지정된 기본 URI와 상대 URI 문자열을 기반으로 Uri 클래스의 새 인스턴스를 초기화합니다.

Uri(Uri, String, Boolean)
사용되지 않음.
사용되지 않음.
사용되지 않음.

문자 이스케이프를 명시적으로 제어하여 지정된 기본 URI와 상대 URI를 기반으로 Uri 클래스의 새 인스턴스를 초기화합니다.

Uri(Uri, Uri)

지정된 기본 Uri 인스턴스와 상대 Uri 인스턴스의 조합을 기반으로 Uri 클래스의 새 인스턴스를 초기화합니다.

필드

SchemeDelimiter

통신 프로토콜 체계를 URI의 주소 부분과 구분하는 문자를 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeFile

URI를 파일 포인터로 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeFtp

FTP(파일 전송 프로토콜)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeFtps

FTPS(파일 전송 프로토콜 보안)를 통해 URI에 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeGopher

Gopher 프로토콜을 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeHttp

HTTP(Hypertext Transfer Protocol)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeHttps

HTTPS(Secure Hypertext Transfer Protocol)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeMailto

URI를 이메일 주소로 지정하고 SMTP(Simple Mail Transport Protocol)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeNetPipe

WCF(Windows Communication Foundation)에서 사용하는 NetPipe 체계를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeNetTcp

WCF(Windows Communication Foundation)에서 사용하는 NetTcp 체계를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeNews

URI를 인터넷 뉴스 그룹으로 지정하고 NNTP(Network News Transport Protocol)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeNntp

URI를 인터넷 뉴스 그룹으로 지정하고 NNTP(Network News Transport Protocol)를 통해 URI에 액세스하도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeSftp

SFTP(SSH 파일 전송 프로토콜)를 통해 URI에 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeSsh

SSH(Secure Socket Shell 프로토콜)를 통해 URI에 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeTelnet

URI가 텔넷 프로토콜을 통해 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeWs

WS(WebSocket 프로토콜)를 통해 URI에 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

UriSchemeWss

WSS(WebSocket Secure Protocol)를 통해 URI에 액세스되도록 지정합니다. 이 필드는 읽기 전용입니다.

속성

AbsolutePath

URI의 절대 경로를 가져옵니다.

AbsoluteUri

절대 URI를 가져옵니다.

Authority

서버의 DNS(Domain Name System) 호스트 이름이나 IP 주소 및 포트 번호를 가져옵니다.

DnsSafeHost

필요한 경우 이스케이프 해제된 후 호스트 이름을 가져오는 것이 DNS 확인에 사용하기에 안전합니다.

Fragment

비어 있지 않은 경우 선행 '#' 문자를 포함하여 이스케이프된 URI 조각을 가져옵니다.

Host

이 인스턴스의 호스트 구성 요소를 가져옵니다.

HostNameType

URI에 지정된 호스트 이름의 형식을 가져옵니다.

IdnHost

Punycode를 적절하게 사용하는 호스트의 RFC 3490 규격 국제 도메인 이름을 가져옵니다. 필요한 경우 이스케이프 해제된 후 이 문자열이 DNS 확인에 사용하기에 안전합니다.

IsAbsoluteUri

절대 Uri 인스턴스인지 여부를 나타내는 값을 가져옵니다.

IsDefaultPort

URI의 포트 값이 이 체계의 기본값인지 여부를 나타내는 값을 가져옵니다.

IsFile

지정된 Uri가 파일 URI인지 여부를 나타내는 값을 가져옵니다.

IsLoopback

지정한 Uri가 로컬 호스트를 참조하는지 여부를 나타내는 값을 가져옵니다.

IsUnc

지정된 Uri가 UNC(범용 명명 규칙) 경로인지 여부를 나타내는 값을 가져옵니다.

LocalPath

파일 이름에 대한 로컬 운영 체제 표현을 가져옵니다.

OriginalString

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

PathAndQuery

물음표(?)로 구분된 AbsolutePathQuery 속성을 가져옵니다.

Port

이 URI의 포트 번호를 가져옵니다.

Query

비어 있지 않은 경우 선행 '?' 문자를 포함하여 지정된 URI에 포함된 쿼리 정보를 가져옵니다.

Scheme

이 URI의 체계 이름을 가져옵니다.

Segments

지정된 URI를 구성하는 경로 세그먼트가 포함된 배열을 가져옵니다.

UserEscaped

Uri 인스턴스를 만들기 전에 URI 문자열을 완전히 이스케이프했는지 여부를 나타내는 값을 가져옵니다.

UserInfo

지정된 URI와 연결된 사용자 이름, 암호 및 기타 사용자 관련 정보를 가져옵니다.

메서드

Canonicalize()
사용되지 않음.
사용되지 않음.
사용되지 않음.

내부적으로 저장된 URI를 정규형으로 변환합니다.

CheckHostName(String)

지정된 호스트 이름이 유효한 DNS 이름인지 여부를 확인합니다.

CheckSchemeName(String)

지정된 체계 이름이 유효한지 여부를 확인합니다.

CheckSecurity()
사용되지 않음.
사용되지 않음.
사용되지 않음.

이 메서드를 호출해도 아무런 효과가 나타나지 않습니다.

Compare(Uri, Uri, UriComponents, UriFormat, StringComparison)

지정된 비교 규칙을 사용하여 두 URI의 지정된 부분을 비교합니다.

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Equals(Object)

Uri 인스턴스가 같은지 비교합니다.

Escape()
사용되지 않음.
사용되지 않음.
사용되지 않음.

경로 구성 요소에서 안전하지 않거나 예약된 문자를 해당 16진 문자 표현으로 변환합니다.

EscapeDataString(ReadOnlySpan<Char>)

URI(Uniform Resource Indentifier)의 개체 표현을 제공하며 URI 부분에 쉽게 액세스할 수 있도록 합니다.

EscapeDataString(String)

문자열을 이스케이프된 표현으로 변환합니다.

EscapeString(String)
사용되지 않음.
사용되지 않음.
사용되지 않음.
사용되지 않음.

문자열을 이스케이프된 표현으로 변환합니다.

EscapeUriString(String)
사용되지 않음.
사용되지 않음.

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

FromHex(Char)

16진수의 10진수 값을 가져옵니다.

GetComponents(UriComponents, UriFormat)

특수 문자에 지정된 이스케이프를 사용하여 현재 인스턴스에 지정된 구성 요소를 가져옵니다.

GetHashCode()

URI의 해시 코드를 가져옵니다.

GetLeftPart(UriPartial)

지정된 Uri 인스턴스 부분을 가져옵니다.

GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext)

현재 인스턴스를 serialize하는 데 필요한 데이터를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
HexEscape(Char)

지정된 문자를 16진수 값으로 변환합니다.

HexUnescape(String, Int32)

지정된 문자의 16진수 표현을 문자로 변환합니다.

InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
IsBadFileSystemCharacter(Char)
사용되지 않음.
사용되지 않음.
사용되지 않음.

파일 시스템 이름에 있는 문자가 잘못되었는지 여부를 나타냅니다.

IsBaseOf(Uri)

현재 Uri 인스턴스가 지정된 Uri 인스턴스의 기본 URI인지 여부를 확인합니다.

IsExcludedCharacter(Char)
사용되지 않음.
사용되지 않음.
사용되지 않음.

지정된 문자가 이스케이프되어야 하는지 여부를 확인합니다.

IsHexDigit(Char)

지정된 문자가 유효한 16진수인지 여부를 확인합니다.

IsHexEncoding(String, Int32)

문자열의 문자가 16진수로 인코딩되었는지 여부를 확인합니다.

IsReservedCharacter(Char)
사용되지 않음.
사용되지 않음.
사용되지 않음.

지정된 문자가 예약된 문자인지 여부를 나타내는 값을 가져옵니다.

IsWellFormedOriginalString()

Uri를 구성하는 데 사용된 문자열의 형식이 올바른지, 이후에 문자열을 이스케이프하지 않아도 되는지 여부를 나타냅니다.

IsWellFormedUriString(String, UriKind)

문자열로 URI 생성을 시도하여 문자열 형식이 올바른지 여부를 나타내고 이후에 문자열을 이스케이프하지 않아도 되는지 확인합니다.

MakeRelative(Uri)
사용되지 않음.
사용되지 않음.
사용되지 않음.
사용되지 않음.

Uri 인스턴스 간의 차이점을 확인합니다.

MakeRelativeUri(Uri)

Uri 인스턴스 간의 차이점을 확인합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Parse()
사용되지 않음.
사용되지 않음.
사용되지 않음.

현재 인스턴스의 URI를 구문 분석하여 유효한 URI에 필요한 모든 부분이 포함되어 있는지 확인합니다.

ToString()

지정된 Uri 인스턴스에 대한 정식 문자열 표현을 가져옵니다.

TryCreate(String, UriCreationOptions, Uri)

지정된 String instance 및 UriCreationOptions를 사용하여 새 Uri 를 만듭니다.

TryCreate(String, UriKind, Uri)

지정된 Uri 인스턴스와 String를 사용하여 새 UriKind를 만듭니다.

TryCreate(Uri, String, Uri)

지정된 기본 및 상대 Uri 인스턴스를 사용하여 새 String를 만듭니다.

TryCreate(Uri, Uri, Uri)

지정된 기본 및 상대 Uri 인스턴스를 사용하여 새 Uri를 만듭니다.

TryEscapeDataString(ReadOnlySpan<Char>, Span<Char>, Int32)

URI(Uniform Resource Indentifier)의 개체 표현을 제공하며 URI 부분에 쉽게 액세스할 수 있도록 합니다.

TryFormat(Span<Char>, Int32)

instance 대한 정식 문자열 표현의 서식을 Uri 지정된 범위로 지정하려고 시도합니다.

TryUnescapeDataString(ReadOnlySpan<Char>, Span<Char>, Int32)

URI(Uniform Resource Indentifier)의 개체 표현을 제공하며 URI 부분에 쉽게 액세스할 수 있도록 합니다.

Unescape(String)
사용되지 않음.
사용되지 않음.
사용되지 않음.

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

UnescapeDataString(ReadOnlySpan<Char>)

URI(Uniform Resource Indentifier)의 개체 표현을 제공하며 URI 부분에 쉽게 액세스할 수 있도록 합니다.

UnescapeDataString(String)

문자열을 이스케이프되지 않은 표현으로 변환합니다.

연산자

Equality(Uri, Uri)

Uri 인스턴스의 값이 같은지를 확인합니다.

Inequality(Uri, Uri)

Uri 인스턴스의 값이 다른지 여부를 확인합니다.

명시적 인터페이스 구현

IFormattable.ToString(String, IFormatProvider)

지정된 형식을 사용하여 현재 인스턴스 값의 형식을 지정합니다.

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

현재 인스턴스를 serialize하는 데 필요한 데이터를 반환합니다.

ISpanFormattable.TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

현재 instance 값의 형식을 제공된 문자 범위로 지정하려고 합니다.

적용 대상

스레드 보안

Uri 모든 멤버는 스레드로부터 안전하며 여러 스레드에서 동시에 사용할 수 있습니다.

추가 정보