Skip to content

UriExtensions Class

Helpers for adding parameters to a URI's query or fragment and for extracting standard parts (origin, trailing slash). Empty or null parameter values are dropped rather than serialized as bare keys, matching the OAuth 2.0 / OpenID Connect convention for absent parameters.

C#
public static class UriExtensions

Inheritance System.Object → UriExtensions

Methods

UriExtensions.AppendTrailingSlash(this string) Method

Appends a trailing slash to a URI string if it does not already end with one.

C#
public static string AppendTrailingSlash(this string uri);

Parameters

uri System.String

The URI string to which a trailing slash will be appended.

Returns

System.String
A string representing the URI with a trailing slash.

UriExtensions.GetOrigin(this Uri) Method

Retrieves the origin (scheme, host, and optionally port) of the given URI.

C#
public static string GetOrigin(this System.Uri uri);

Parameters

uri System.Uri

The URI from which the origin will be extracted.

Returns

System.String
A string representing the origin of the URI.