相关疑难解决方法(0)

该请求需要缓冲数据以成功HttpClient

我正在尝试使用POST方法将字典内容发送到服务器

public async Task<T> postConnection(string GETParam, Dictionary<string, string> values, bool isRegistration = false)
{
    HttpResponseMessage response;
    string responseString;
    try
    { 
        using (var client = new HttpClient() { MaxResponseContentBufferSize = 256000 }) 
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tocken);
            var content = new FormUrlEncodedContent(values);
            response = await client.PostAsync(url, content);
            responseString = await response.Content.ReadAsStringAsync();
        }
    }
Run Code Online (Sandbox Code Playgroud)

但是当我运行代码时,它给了我错误
WebException: The request requires buffering data to succeed HttpClient.

我不想使用WebRequest或请求WebClient,我只想使用HttpClient.

一个问题已经存在,当尝试发送一个head request说只是在Xamarin …

c# xamarin.forms

10
推荐指数
1
解决办法
2808
查看次数

标签 统计

c# ×1

xamarin.forms ×1