R
Richard.Haggard
Guest
I'm trying to call GetAsync on my HttpClient object but the call just hangs forever.
This is the (slightly obfuscated) URL that works from an internet browser:
http://HostingMachine/TheService/ThePage.asmx/HasAdminRights?user=RHaggard&computer=WS-RHAGGARD
My WPF C# test program is very simple. It has an HttpClient object that is named httpClient and defined as a static member. In the class's static constructor httpClient is instantiated and its BaseAddress member is loaded with a Uri containing http://HostingMachine/TheService/ThePage.asmx .
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
string user = Environment.GetEnvironmentVariable("USERNAME");
string computer = Environment.GetEnvironmentVariable("COMPUTERNAME");
// This string will look like this:
// HasAdminRights?user=RHaggard&computer=WS-RHAGGARD
string subAddr = string.Format("{0}?user={1}&computer={2}", func, user, computer);
// This is where the program stalls.
// It never returns from the GetAsync.
HttpResponseMessage resp = await httpClient.GetAsync(subAddr);
if (resp.IsSuccessStatusCode)
{
string strResp = await resp.Content.ReadAsStringAsync();
}
Richard Lewis Haggard
Continue reading...
This is the (slightly obfuscated) URL that works from an internet browser:
http://HostingMachine/TheService/ThePage.asmx/HasAdminRights?user=RHaggard&computer=WS-RHAGGARD
My WPF C# test program is very simple. It has an HttpClient object that is named httpClient and defined as a static member. In the class's static constructor httpClient is instantiated and its BaseAddress member is loaded with a Uri containing http://HostingMachine/TheService/ThePage.asmx .
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
string user = Environment.GetEnvironmentVariable("USERNAME");
string computer = Environment.GetEnvironmentVariable("COMPUTERNAME");
// This string will look like this:
// HasAdminRights?user=RHaggard&computer=WS-RHAGGARD
string subAddr = string.Format("{0}?user={1}&computer={2}", func, user, computer);
// This is where the program stalls.
// It never returns from the GetAsync.
HttpResponseMessage resp = await httpClient.GetAsync(subAddr);
if (resp.IsSuccessStatusCode)
{
string strResp = await resp.Content.ReadAsStringAsync();
}
Richard Lewis Haggard
Continue reading...