私はJSON形式でのHttpClientを使用してサーバーに画像や他のフィールドを送信しています。 「Excepionalエラー」:私は私のフロントカメラを持っている小さな画像を送信する場合、私はそれが動作しないと私は常に例外を取得リアカメラを持っている大きな画像を送信する場合 それは、正常に動作しています。Xamarin.Formsの問題は、私のXamarin.Formsアプリから
私は、Windowsフォームアプリケーションで同じコードを作成しようと、それは大きな画像ではなく、私のアプリからも正常に動作しています。
<jsonSerialization maxJsonLength="50000000"/>
誰かが助けることができます:
は、私はすでにJSONコンテンツのサイズを大きくするために、サーバーのweb.configファイルに変更しました?!ありがとう!!
これが私のアプリのコードです:スタックトレースから
public async static Task<MyAppDataModels.Common.WsResponse> PostPhotoFromUser(int catalogItemId, int objReferenceId, int languageId, byte[] fileContent)
{
MyAppDataModels.Common.WsResponse MyResponse = new MyAppDataModels.Common.WsResponse();
try
{
HttpClient MyHttpClient = new HttpClient();
MyHttpClient.Timeout = TimeSpan.FromSeconds(520);
MyHttpClient.BaseAddress = new Uri(string.Format("{0}/Application/ApplicationPostPhotoFromUser", MyAppSettings.ServerApiUrl));
MyHttpClient.DefaultRequestHeaders.Accept.Clear();
MyHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
MyHttpClient.DefaultRequestHeaders.AcceptCharset.Clear();
MyHttpClient.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
HttpRequestMessage MyWsRequest = new HttpRequestMessage(HttpMethod.Post, MyHttpClient.BaseAddress);
dynamic MyObjData = new JObject();
MyObjData["CatalogItemId"] = catalogItemId;
MyObjData["ObjReferenceId"] = objReferenceId;
MyObjData["UserId"] = string.Empty;
MyObjData["LanguageId"] = languageId;
MyObjData["Picture"] = fileContent;
string MySerializedPostedData = JsonConvert.SerializeObject(MyObjData);
MyWsRequest.Content = new StringContent(MySerializedPostedData, Encoding.UTF8, "application/json");
HttpResponseMessage MyWsResponse = await MyHttpClient.SendAsync(MyWsRequest, HttpCompletionOption.ResponseHeadersRead);
MyWsResponse.EnsureSuccessStatusCode();
var MyContentResponse = await MyWsResponse.Content.ReadAsStringAsync();
MyResponse.ResponseId = MyAppConstants.Constants.ResponseCode.Successfull;
}
catch (Exception ex)
{
MyResponse.ResponseId = MyAppConstants.Constants.ResponseCode.ErrorWhileProcessingRequest;
MyResponse.ResponseErrorMessage = ex.Message;
}
return MyResponse;
}
完全なスタックトレースを投稿できますか? – SushiHangover
これはどのアプリで動作していませんか? iOSまたはAndroid? –
私はXamarin.FormsとPCL内部のコードを使用しています。この場合、私はAndroid上でアプリケーションを実行しています。 – Stefano