小编Die*_*ego的帖子

即使AllowAutoRedirect = true,HttpClient也不会重定向

我正在尝试解析wiki空间页面,但我无法获得实际页面.我不确定它是否是一个HttpClient错误或一些丢失的配置.

这是我的代码:

HttpClientHandler handler = new HttpClientHandler();
handler.AllowAutoRedirect = true;
_httpClient = new HttpClient(handler);

HttpResponseMessage response = await _httpClient
    .GetAsync("http://medivia.wikispaces.com/Monsters");
Run Code Online (Sandbox Code Playgroud)

当我运行该代码时,我得到StatusCode 302并被发送到https://session.wikispaces.com/1/auth/auth?authToken=token.我希望HttpClient能够跟随302,因为我有AllowAutoRedirect = true.

这是我第一次遇到这个问题.它适用于Postman和RestClient,它是RestSharp的一部分.

.net c# dotnet-httpclient .net-core

5
推荐指数
1
解决办法
3054
查看次数

标签 统计

.net ×1

.net-core ×1

c# ×1

dotnet-httpclient ×1