Just a quick post as I’ve just fallen foul of this.
Recently I changed by web-client to use the nice await/async HttpClient, e.g.
HttpClient client = new HttpClient(); string result = await webClient.GetStringAsync(serviceRequest);
The problem is that my service decided to be a good web citizen and change their API by sending a redirect. Unfortunatley the above code simple fell over…legs in the air.
The trick is to configure the HttpClient to allow redirects;
HttpClientHandler handler = new HttpClientHandler(); handler.AllowAutoRedirect = true; HttpClient webClient = new HttpClient(handler); string result = await webClient.GetStringAsync(serviceRequest);