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

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

am 22.01.2008 04:22:40 von 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

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

am 22.01.2008 08:52:55 von wawang

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 (wawang@online.microsoft.com, 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.