Is there an existing .NET method for combining querystring vars correctly?

K

Ken Fine

I am wondering if there is a build-in method in .NET for arbitrarily and
correctly combining/concatenating querystring variables into a valid
querystring.

i.e. I might have the following vars I want to put into a valid querystring:
id=200
action=doStuff

I have a user control that might sometimes be appending vars to a URL that
might have no vars:

http://whatever.com/index.asp

....or might have one var:

http://whatever.com?foo=bar

....or might have several values...

http://whartever.com?foo=bar&max=200

or might have # "fragment identfiers"/anchor references mixed in.

Is there a .NET method that will tack on a new variable to a valid
querystring in the correct form, or do I need to make this myself? This is
not hard but someone else has already done the work, I'll take that.

-KF
 
W

Walter Wang [MSFT]

Hi Ken,

There's no built-in function to help you achieve this but if you need to
implement it yourself, inheriting from UriBuilder should be the easiest
approach; for example:

Extended UriBuilder to get/set individual querystring items... - ASP.NET
Forums (http://forums.asp.net/t/693414.aspx)

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top