httpClient postAsync -> Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStr RRS feed

  • Question

  • User85973 posted

    Hello all, we have an app with xamarin android c# Visual studio 2017 who works since three years WITHOUT problems... But since two weeks and I don't know why the driver can't sync the work with our system...

    Nothing has change in this part of the app...

    if I put a break point inside the method postAsync I have this log > Cannot access a disposed object. Object name: 'System.Net.Sockets.NetworkStream

    Anyone has an idea about this ? How i can solve this problem ?

    It's enough strange because it's arrive NOT on all device just for me device and the http client can 't arrive to the server -> we have no trace !


    Here is it the code of the postAsync

    ` public override HttpResult ExecutePost(Uri target, string body) { var client = new HttpClient(); client.MaxResponseContentBufferSize = MaxHttpResponseBufferSize;

                var requestContent = new StringContent(body, RequestContentEncoding, RequestContentType);
                var response = client.PostAsync(target, requestContent).Result;
                if (response.IsSuccessStatusCode)
                    var content = response.Content.ReadAsStringAsync().Result;
                    return new HttpResult(content, null, null);
                return new HttpResult(null, "Empty response received for remote POST invokation", response.StatusCode.ToString());
            catch (Exception e)
                return new HttpResult(null, "Error on postAsync", e.Message);


    Tuesday, June 9, 2020 8:56 AM

All replies

  • User85973 posted

    Hello all, problem SOLVE !

    here is it the problem. we have add the database production in test. Send the json to the database test with postman , the result was -> ENTITY TOO LARGE !

    the json size is 1.2 mega and the default value inside IIS is by default one mega !!!!

    two days for this little problem ...

    Hope this step to solve this problem will be read :)

    Wednesday, June 10, 2020 2:16 PM