How to get query string from a URL in C#

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

string urlString = "";
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");



About author

User avatar

Waqas Anwar

Founder of, Senior Consultant, Microsoft .NET and Web Technologies