Mega Code Archive

 
Categories / C# Book / 08 Net
 

0592 Query Strings

A query string is a string appended to a URI with a question mark. A query string is used to send simple data to the server. You can specify multiple key/value pairs in a query string with the following syntax: ?key1=value1&key2=value2&key3=value3... WebClient provides an easy way to add query strings through a dictionary-style property. using System; using System.Net; using System.Threading; class ThreadTest { static void Main() { WebClient wc = new WebClient(); wc.Proxy = null; wc.QueryString.Add("q", "WebClient"); // Search for "WebClient" \ wc.QueryString.Add("hl", "fr"); // Display page in French wc.DownloadFile("http://www.google.com/search", "results.html"); System.Diagnostics.Process.Start("results.html"); } }