Skip to content

UriBuilder Class

A wrapper around System.UriBuilder, providing enhanced functionality for URI manipulation, specifically for handling query strings and fragments.

C#
public class UriBuilder

Inheritance System.Object → UriBuilder

Constructors

UriBuilder(string) Constructor

Initializes a new instance of the UriBuilder class with the specified URI string. Automatically detects and handles both absolute URIs and relative paths.

C#
public UriBuilder(string uri);

Parameters

uri System.String

A URI string to use as the base of the UriBuilder. Can be an absolute URI (e.g., "https://example.com/path"\) or a relative path (e.g., "/path").

UriBuilder(Uri) Constructor

Initializes a new instance of the UriBuilder class with the specified Uri instance. Supports both absolute and relative URIs.

C#
public UriBuilder(System.Uri uri);

Parameters

uri System.Uri

The Uri instance to use as the base of the UriBuilder.

Properties

UriBuilder.Fragment Property

ParametersBuilder for the fragment part of the URI. Used for OAuth/OIDC implicit flow where parameters are passed in fragments.

C#
public Abblix.Utils.ParametersBuilder Fragment { get; }

Property Value

ParametersBuilder

UriBuilder.Path Property

The path part of the URI.

C#
public string Path { get; set; }

Property Value

System.String

Remarks

Typed as a plain string rather than the framework's PathString: this is a foundation library, and that type would put an ASP.NET Core dependency on every package beneath the server, including hosts that never serve HTTP. A caller holding a PathString still assigns and reads it, since that type converts to and from string implicitly.

UriBuilder.Query Property

ParametersBuilder for the query string.

C#
public Abblix.Utils.ParametersBuilder Query { get; }

Property Value

ParametersBuilder

UriBuilder.Uri Property

The URI constructed by the UriBuilder. For relative URIs, returns the path, query, and fragment without scheme and host.

C#
public System.Uri Uri { get; }

Property Value

System.Uri

Remarks

Note: This property has side effects (updates internal builder state) and is not thread-safe. If thread safety is required, synchronize access to this instance externally.

Operators

UriBuilder.implicit operator string(UriBuilder) Operator

Converts a UriBuilder instance to a string.

C#
public static string implicit operator string(Abblix.Utils.UriBuilder builder);

Parameters

builder UriBuilder

The UriBuilder instance to convert.

Returns

System.String

UriBuilder.implicit operator Uri(UriBuilder) Operator

Converts a UriBuilder instance to a Uri.

C#
public static System.Uri implicit operator System.Uri(Abblix.Utils.UriBuilder builder);

Parameters

builder UriBuilder

The UriBuilder instance to convert.

Returns

System.Uri