Q:

How to query string to a web site using get method?

I want to send an information along with the url like a query string to the web site. This is exactly I call
Process.Start("http://domain.com?value=anything");

but I don't want to open browser because don't want to interrupt the user who is using the software.
I have googled for this but I found some HttpRequest code but the problem is this those program is not appending the query string. They are just returning me the html text of the web page.
I want to retrieve that information to store in database. Please guide me in this case. 

A:

Use WebClient.DownloadString to get a page from a specific url, without using browsers:
var x = WebClient.DownloadString("http://domain.com?value=anything");

A:

Here is something I use to perform a GET:
public T Get<T>(string url, IEnumerable<KeyValuePair<string, string>> data)
{
    var webApiUri = ConfigurationManager.AppSettings["WebApiUri"];

    var client = new HttpClient();

    try
    {
        string queryString = string.Empty;

        if (data != null)
        {
            queryString = data.Distinct().Select(x => string.Format("{0}={1}", x.Key, x.Value)).ToDelimitedString("&");
        }

        var response = client.GetAsync(string.Format("{0}/{1}?{2}", webApiUri, url, queryString)).Result;
        var responseContent = response.Content.ReadAsStringAsync().Result;
        return JsonConvert.DeserializeObject<T>(responseContent);
    }
    catch (Exception ex)
    {
        Debug.Assert(false, ex.Message);
        throw;
    }
}

T is the return type of the method. The response is expected as JSON, but you don't have to worry about that part. It's how the client performs a GET request that you're interested in. This is just example based around a JSON result. 

