Error 500 when I try to give a JSON post to the web service C #

0

I have a WINDOWS FORM C # application, where I communicate with a web service, when I try to send a very large data from my application to the web service I get error 500.

I can do a POST on any other object in JSON, but when it is this one that contains very large data it gives dick, the interesting fact is that if I try to give a get I can retrieve this data for my application, just do not I can send it to the server.

The large data is, a photo converted to base64 and a binary file that is also converted to base64.

Then follow the code that makes the post

public void POST(string url, string jsonContent)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";

        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        Byte[] byteArray = encoding.GetBytes(jsonContent);

        request.ContentLength = byteArray.Length;
        request.ContentType = @"application/json";


        using (Stream dataStream = request.GetRequestStream())
        {
            dataStream.Write(byteArray, 0, byteArray.Length);
        }
        long length = 0;
        try
        {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                length = response.ContentLength;
            }
        }
        catch (WebException ex)
        {

            // Log exception and throw as for GET example above
        }
    }

This method works cool with smaller jsons.

Who does have a notion of how I can solve this problem?

    
asked by anonymous 16.12.2015 / 22:24

1 answer

0

The first thing I would do would be this config in WS:

<configuration>
  <system.web>
  <httpRuntime maxMessageLength="409600"
    executionTimeoutInSeconds="300"/>
  </system.web>
</configuration>

If you still have not resolved, there are other options. Here you can better see all the options that the framework has there.

    
16.12.2015 / 22:28