I recently published UriBuilderExtended , which is a library that allows you to edit query strings on UriBuilder
objects like the wind through extension methods.
Basically, you create a UriBuilder
object with the current URL string in the constructor, modify the request using extension methods, and create a new URL string from the UriBuilder
object.
Quick example:
string myUrl = "http://www.example.com/?idProject=10&idService=14"; UriBuilder builder = new UriBuilder(myUrl); builder.SetQuery("idProject", "12"); builder.SetQuery("idService", "7"); string newUrl = builder.Url.ToString();
The URL string is obtained from builder.Uri.ToString()
, not builder.ToString()
, as it sometimes differs from what you expect.
You can get the library through NuGet .
Additional examples here .
Comments and suggestions are welcome.
source share