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

Discussion in 'ASP .Net' started by Ken Fine, Jan 22, 2008.

  1. Ken Fine

    Ken Fine Guest

    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
    Ken Fine, Jan 22, 2008
    #1
    1. Advertising

  2. 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 (, 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.
    Walter Wang [MSFT], Jan 22, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon

    app vars and cache vars

    Jon, Dec 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    392
  2. Replies:
    0
    Views:
    468
  3. Linuxguy123
    Replies:
    7
    Views:
    683
    Paddy O'Loughlin
    Feb 20, 2009
  4. caccolangrifata
    Replies:
    18
    Views:
    392
    Chris Torek
    Jul 22, 2011
  5. HopfZ
    Replies:
    2
    Views:
    120
    HopfZ
    Aug 25, 2006
Loading...

Share This Page