Good way to parse query string

Posted by m.edmondson on Stack Overflow See other posts from Stack Overflow or by m.edmondson
Published on 2011-01-10T11:51:16Z Indexed on 2011/01/10 11:53 UTC
Read the original article Hit count: 205

Filed under:
|
|
|
|

I have a String that contains the following:

?workarea=London+&+Home+Counties+Ltd&sub=fs&&&FASh*5

which resembles a URI query string. What is the best way to parse the elements of this string (workarea and sub) without messing about with string manipulation?

If I use HttpUtility.ParseQueryString is gets stuck as both elements include &. However if I encode the whole thing first I lose the seperations of the elements. Ideally the output would be:

  • workarea = London & Home Counties Ltd
  • sub = fs&&&FASh*5

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about parsing