我尝试解析一个Wikispaces页面,但是我不能获取实际页面。我不确定这是HttpClient的错误还是一些缺失的配置。
这是我的代码:
HttpClientHandler handler = new HttpClientHandler();
handler.AllowAutoRedirect = true;
_httpClient = new HttpClient(handler);
HttpResponseMessage response = await _httpClient
.GetAsync("http://medivia.wikispaces.com/Monsters");
当我运行该代码时,我得到状态码302并被发送到https://session.wikispaces.com/1/auth/auth?authToken=token。我期望HttpClient会遵循302,因为我已经设置了AllowAutoRedirect = true
。这是我第一次遇到这个问题。在Postman和RestSharp的RestClient中可以正常工作。
handler.AllowAutoRedirect = false;
。 - giubuenoWebClient
太老旧了,太可怕了,需要死得惨烈而痛苦! - DavidG