我正在使用 Windows 10 通用应用程序,当我尝试执行以下操作时,我不断收到“HTTP 重定向请求必须由用户确认”错误:
HttpClient http = new HttpClient();
HttpResponseMessage response = new HttpResponseMessage();
response = await http.PutAsync(url, new StringContent(temp));
关于如何处理的任何想法?
我正在使用 Windows 10 通用应用程序,当我尝试执行以下操作时,我不断收到“HTTP 重定向请求必须由用户确认”错误:
HttpClient http = new HttpClient();
HttpResponseMessage response = new HttpResponseMessage();
response = await http.PutAsync(url, new StringContent(temp));
关于如何处理的任何想法?
通过将 AllowAutoRedirect 设置为 false 然后手动调用重定向,我设法找到了解决该问题的方法。
HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.AllowAutoRedirect = false;
HttpClient http = new HttpClient(clientHandler);
HttpResponseMessage response = new HttpResponseMessage();
response = await http.PutAsync(url, new StringContent(temp));
url = response.Headers.Location;
response = await http.PutAsync(url, new StringContent(temp));