How to get query string from a URL in C#

Waqas Anwar
22 August 2014
6220 Views

Following code snippet shows you how to get query string from a url using c#.

string urlString = "http://www.ezzylearning.com/Default.aspx?technology=Java&id=5&year=2015";
Uri uri = new Uri(urlString);
string queryString = uri.Query;


If you want to get the value of individual query string parameter then you can use following code snippet.

string technology = System.Web.HttpUtility.ParseQueryString(queryString).Get("technology");