UriBuilderExtended 1.2.1

.NET Framework 4.5
Install-Package UriBuilderExtended -Version 1.2.1
dotnet add package UriBuilderExtended --version 1.2.1
<PackageReference Include="UriBuilderExtended" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UriBuilderExtended --version 1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: UriBuilderExtended, 1.2.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install UriBuilderExtended as a Cake Addin
#addin nuget:?package=UriBuilderExtended&version=1.2.1

// Install UriBuilderExtended as a Cake Tool
#tool nuget:?package=UriBuilderExtended&version=1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


Extensions to .NET's System.UriBuilder.

Maintainers wanted!

  • Would you like to maintain UriBuilderExtended?
  • Alternatively include it in your own library project where it makes sense?
  • Are you from microsoft and wants to put this code into UriBuilder?

If you can answer yes to any of these questions, then you are most welcome! I have shifted path and do not work with C# and .NET anymore. Therefore I would like to hand over this project to someone who can keep the code alive.


A thing that is missing from .NET's System.UriBuilder is a good way to edit the query string. That is what made me look for others solution to this problem, and ultimately made me start this project.

Other good solutions exist that may cover your needs, but I was unable to find one that that covered my requirements:

  1. Do anything UriBuilder does
  2. Set the query string with support for multiple values
  3. Be as simple as possible

I have built this with great inspiration from URI.js, which is a very good library for modifying URIs in JavaScript.


Install the package from NuGet

Add using UriBuilderExtended; to your source files, and you will have the following methods available on your UriBuilder objects:

bool HasQuery(string key) Check for the existence of a query with the given key

bool HasQuery(string key, params string[] values) Check for the existence of a query with the given key and the given values

UriBuilder RemoveQuery(string key) Remove any query with the given key

UriBuilder SetQuery(string key, params string[] values) Sets the query parameter for a given key

UriBuilder AddQuery(string key, params string[] values) Adds a query parameter for a given key

List<string> GetQueryValues(string key) Get all values for the given key


    UriBuilder builder = new UriBuilder("http://www.mysite.net/");
    // URL is now http://www.mysite.net/
    // URL string  is obtained from builder.Uri.ToString(), not builder.ToString()
    // as it sometimes renders differently to what you'd expect

    builder.AddQuery("myKey", "myValue1");
    // URL is now http://www.mysite.net/?myKey=myValue1

    builder.AddQuery("myOtherKey", "myOtherValue1");
    // URL is now http://www.mysite.net/?myKey=myValue1&myOtherKey=myOtherValue1

    builder.AddQuery("myKey", "myValue2", "myValue3");
    // URL is now http://www.mysite.net/?myKey=myValue1&myKey=myValue2&myKey=myValue3&myOtherKey=myOtherValue1

    builder.SetQuery("myKey", "newValue1", "newValue2");
    // URL is now http://www.mysite.net/?myOtherKey=myOtherValue1&myKey=newValue1&myKey=newValue2

    // true

    builder.HasQuery("myKey", "myValue1");
    // false

    builder.HasQuery("myKey", "newValue1");
    // true

    // false

    // An ICollection containing values "newValue1" and "newValue2"
Product Versions
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 25,180 6/1/2016
1.2.0 981 6/1/2016
1.1.0 959 6/1/2016

     Added GetQueryKeys method.
     Added GetQueryValues method.
     First stable release. Changed version scheme.