Link to home
Start Free TrialLog in
Avatar of Bharat Guru
Bharat Guru

asked on

C# HTTP GET method sample code

Looking for C# HTTP GET method sample code where I can pass in multiple key and value and received the return string.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are sending data, a POST is the standard resquest type

using (var client = new HttpClient())
{
    var values = new Dictionary<string, string>
    {
       { "thing1", "hello" },
       { "thing2", "world" }
    };

    var content = new FormUrlEncodedContent(values);

    var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);

    var responseString = await response.Content.ReadAsStringAsync();
}

Open in new window

Avatar of Bharat Guru
Bharat Guru

ASKER

Thanks