How to

parse URL query string

Published: 5. February 2015 | Updated: 5. February 2015
License: Microsoft Public License (MS-PL)
Categories: Network
Tags: C# Network Text
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Import namespaces

using System;
using System.Web;

Code

var query = "?param1=abc&param2=512";
var collection = HttpUtility.ParseQueryString(query);

foreach (string key in collection)
{
    Console.WriteLine("{0} = {1}", key, collection[key]);
}
Console Output:
param1 = abc
param2 = 512
Send us feedback about this snippet »



Related Snippets: