I wrote a simple client for my web service with Web Api as explained in this tutorial:
http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client
The first request (GET a table) is executed successfully. That is, table data is fetched from the web service and bound to TableContent object.
But the program is totally blocked before executing the second request (GET table list); nothing happens, not even an error message!
If I comment out the code section related with the first request (GET a table) the second request (GET table list) is executed successfully.
What happens here? Why can this client execute only a single GET request?
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:56510/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response;
// GET a table from web service
response = await client.GetAsync("api/table/GetMatrixTable");
if (response.IsSuccessStatusCode)
{
var tblcont = await response.Content.ReadAsAsync<TableContent>();
// do things ...
}
// GET a table list from web service
response = await client.GetAsync("api/table/GetTableList");
if (response.IsSuccessStatusCode)
{
var TblContList = await response.Content.ReadAsAsync<IList<TableContent>>();
// do things ...
}
}