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

 

 

About author


User avatar

Waqas Anwar

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

Comments