UriHelper Class¶
A helper class for constructing encoded Uris for use in headers and other Uris.
- Namespace
Microsoft.AspNetCore.Http.Extensions
- Assemblies
- Microsoft.AspNetCore.Http.Extensions
Methods¶
-
BuildAbsolute
(System.String, Microsoft.AspNetCore.Http.HostString, Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.QueryString, Microsoft.AspNetCore.Http.FragmentString)¶ Combines the given URI components into a string that is properly encoded for use in HTTP headers. Note that unicode in the HostString will be encoded as punycode.
Arguments: - scheme (System.String) – http, https, etc.
- host (Microsoft.AspNetCore.Http.HostString) – The host portion of the uri normally included in the Host header. This may include the port.
- pathBase (Microsoft.AspNetCore.Http.PathString) – The first portion of the request path associated with application root.
- path (Microsoft.AspNetCore.Http.PathString) – The portion of the request path that identifies the requested resource.
- query (Microsoft.AspNetCore.Http.QueryString) – The query, if any.
- fragment (Microsoft.AspNetCore.Http.FragmentString) – The fragment, if any.
Return type: System.String
public static string BuildAbsolute(string scheme, HostString host, PathString pathBase = null, PathString path = null, QueryString query = null, FragmentString fragment = null)
-
BuildRelative
(Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.PathString, Microsoft.AspNetCore.Http.QueryString, Microsoft.AspNetCore.Http.FragmentString)¶ Combines the given URI components into a string that is properly encoded for use in HTTP headers.
Arguments: - pathBase (Microsoft.AspNetCore.Http.PathString) – The first portion of the request path associated with application root.
- path (Microsoft.AspNetCore.Http.PathString) – The portion of the request path that identifies the requested resource.
- query (Microsoft.AspNetCore.Http.QueryString) – The query, if any.
- fragment (Microsoft.AspNetCore.Http.FragmentString) – The fragment, if any.
Return type: System.String
public static string BuildRelative(PathString pathBase = null, PathString path = null, QueryString query = null, FragmentString fragment = null)
-
Encode
(System.Uri)¶ Generates a string from the given absolute or relative Uri that is appropriately encoded for use in HTTP headers. Note that a unicode host name will be encoded as punycode.
Arguments: uri (System.Uri) – The Uri to encode. Return type: System.String public static string Encode(Uri uri)
-
GetDisplayUrl
(Microsoft.AspNetCore.Http.HttpRequest)¶ Returns the combined components of the request URL in a fully un-escaped form (except for the QueryString) suitable only for display. This format should not be used in HTTP headers or other HTTP operations.
Arguments: request (Microsoft.AspNetCore.Http.HttpRequest) – The request to assemble the uri pieces from. Return type: System.String public static string GetDisplayUrl(this HttpRequest request)
-
GetEncodedUrl
(Microsoft.AspNetCore.Http.HttpRequest)¶ Returns the combined components of the request URL in a fully escaped form suitable for use in HTTP headers and other HTTP operations.
Arguments: request (Microsoft.AspNetCore.Http.HttpRequest) – The request to assemble the uri pieces from. Return type: System.String public static string GetEncodedUrl(this HttpRequest request)
-