Header Ads

C#.NET: How to Build Web URL Query Parameters

While working with Web API(s), especially those that require query parameter passing, it is often required to build those query parameters in order to attach them with the web URL. Asmak9.EssentialToolKit library provides many feature methods and building web URL query parameter is one of them.

Today, I shall be demonstrating building web URL query parameter method of Asmak9.EssentialToolKit .NET library using C#.NET console application.


Following are some prerequisites before you proceed any further in this tutorial:
  1. Install Asmak9.EssentialToolKit Nuget Package.
  2. Knowledge of Nuget Package Manager.
  3. Knowledge of C# Programming.
The example code is being developed in Microsoft Visual Studio 2019 Professional. 

Download Now!

Let's begin now.

1) Create new C#.NET console application and name it "BuildUrlParams".  
2) Open "Tools\Nuget Package Manage\Manage Nuget Packages for Solution...".

3) Install Asmak9.EssentialToolKit Nuget Package.

4) Now, create "BuildUrlParams.cs" file and type following lines of code i.e.


// Initialization
List<KeyValuePair<string, string>> lstParams = new List<KeyValuePair<string, string>>();

// Settings.
lstParams.Add(new KeyValuePair<string, string>("param1", "val1"));
lstParams.Add(new KeyValuePair<string, string>("param2", "val2"));
lstParams.Add(new KeyValuePair<string, string>("param3", "val3"));

// Build URL Query Parameters method


The above code shows how you can build your web URL query parameter by simply passing parameters key-value pair list. You also need to initialize 'UtilityKit' class with or without your license key.

5) Now, execute the project and you will be able to see the following i.e.


In this article, you will learn to build web URL query parameter using Asmak9.EssentialToolKit library with C#.NET console application. You will also learn to make key-value pair list for your query parameters.

No comments