Dreteh
Dreteh

Reputation: 387

C# ASP.NET : Dynamically constructing an url query string

I need to dynamically construct a url by appending new parameter to the current url.

I know how to do this in the long way by getting the current url and check if there is any QueryString, if no add "?" if yes add "&". Also check is the parameter is already exist. If yes change the value.

But is there any build in .NET function to do this? Like Request.QueryString.Add

Thanks.

Upvotes: 3

Views: 2688

Answers (1)

twesh
twesh

Reputation:

No, there is no built-in method in .Net, you'll have to check manually if url contains ? then add new querystring. or if the parameter already exists then update the value.

Upvotes: 1

Related Questions