VB.NET || How To Get, Add, Update & Remove Values From A URL Query String Using VB.NET

The following is a module with functions which demonstrates how to get, add, update and remove parameters from a query string using C#.

The following functions use System.Web to modify the url.

To use the functions in this module, make sure you have a reference to ‘System.Web‘ in your project.

One way to do this is, in your Solution Explorer (where all the files are shown with your project), right click the ‘References‘ folder, click ‘Add Reference‘, then type ‘System.Web‘ in the search box, and add the reference titled System.Web in the results Tab.

Note: Don’t forget to include the ‘Utils Namespace‘ before running the examples!


1. Add – Single Parameter

The example below demonstrates the use of ‘Utils.HttpParams.Add‘ to add a query string parameter to a url.


2. Add – Multiple Parameters

The example below demonstrates the use of ‘Utils.HttpParams.Add‘ to add a query string parameter to a url.


3. Update – Single Parameter

The example below demonstrates the use of ‘Utils.HttpParams.Update‘ to update a query string parameter to a url.


4. Update – Multiple Parameters

The example below demonstrates the use of ‘Utils.HttpParams.Update‘ to update a query string parameter to a url.


5. Remove – Single Parameter

The example below demonstrates the use of ‘Utils.HttpParams.Remove‘ to remove a query string parameter from a url.


6. Remove – Multiple Parameters

The example below demonstrates the use of ‘Utils.HttpParams.Remove‘ to remove multiple query string parameters from a url.


7. Clear – Remove All Parameters

The example below demonstrates the use of ‘Utils.HttpParams.Clear‘ to remove all query string parameters from a url.


8. Get – Get All Parameters

The example below demonstrates the use of ‘Utils.HttpParams.Get‘ to get all query string parameters from a url.


9. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


10. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Was this article helpful?
👍 YesNo

Leave a Reply