私はウェブAPIを持っています
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 値に設定することにしました。これは私のローカル マシンでは機能しますが、ビルド ボックスで次のエラーが発生します: Method not found: 'Void System.Net.Http.HttpClient.set_MaxResponseContentBufferSize(Int64)
私は今何をすべきか分かりません。