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

Syntax

public class UriHelper
class Microsoft.AspNetCore.Http.Extensions.UriHelper

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:
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:
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)