Shadow
Shadow

Reputation: 2478

Editing querystring in aspnet core

My simple usecase is changing page number. Like: http://localhost?page=1 to: http://localhost?page=2

I would like to be able to add/update/remove segments from querystring.

There are QueryString and QueryBuilder classes, however they support only adding segments, not changing them. WebUtilities.QueryHelpers parses querystring to dictionary, but that is hard to edit, because you need to create variable, and also you need to check if key exists.

My frontend engineers need simple and foolproof way of manipulating it, to use with server generated url or IUrlHelper. Is there builtin way of doing it?

My ideal api:

Query(Model.Uri).Update('page', '2').Add('sort', 'asc').Remove('filter').ToString();

Upvotes: 1

Views: 76

Answers (1)

arnaudauroux
arnaudauroux

Reputation: 750

Try Flurl, it is the perfect tool for what your need ;)

Upvotes: 3

Related Questions