当我使用HttpClient.GetAsync(url)时,但是url不是可访问的地址,但它总是重定向到另一个地址,并且它返回一个带有ok的statuecode。
var httpClient = new HttpClient(handler);
httpClient.DefaultRequestHeaders.ExpectContinue = false;
//using ()
{
HttpResponseMessage response = new HttpResponseMessage();
response = await httpClient.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync();
Debug.WriteLine(response.StatusCode.ToString());
}
else
{
// problems handling here
Debug.WriteLine(
"Error occurred, the status code is: {0}",
response.StatusCode
);
}
}