我有一个webapi
public ISearchProviderCommandResult ExecuteCommand(ISearchProviderCommand searchCommand)
{
//serialize the object before sending it in
JavaScriptSerializer serializer = new JavaScriptSerializer();
string jsonInput = serializer.Serialize(searchCommand);
HttpClient httpClient = new HttpClient() { BaseAddress = new Uri(ServiceUrl), MaxResponseContentBufferSize = 256000 };
StringContent content = new StringContent(jsonInput, Encoding.UTF8, "application/json");
HttpResponseMessage output = httpClient.PostAsync(ServiceUrl, content).Result;
//deserialize the output of the webapi call
SearchProviderCommandResult searchResult = serializer.Deserialize<SearchProviderCommandResult>(output.Content.ReadAsStringAsync().Result);
return searchResult;
}
在我的本地机器上是否设置了MaxResponseContentBufferSize,它似乎以我想要的方式检索数据。但是在我们的构建环境中,如果我没有设置MaxResponseContentBufferSize,我会收到此错误: 无法向缓冲区写入比配置的最大缓冲区大小更多的字节:65536。
在google上查看后,我决定将MaxResponseContentBufferSize设置为任意256000值。即使这适用于我的本地计算机,在生成框上我收到此错误: 找不到方法:'Void System.Net.Http.HttpClient.set_MaxResponseContentBufferSize(Int64)
我不知道现在该做什么。