how can i upload a large string (in my case XML with BLOB) with POST without getting Timeout with GetResponse?
Changing the timeout helps, but this isn't really a solution. If the Server is really death or the POST was interrupted i have to wait for the extrem large timeout.
Any Idea?
HttpWebRequest webRequest = null;
string response = "";
byte[] bytes = Encoding.UTF8.GetBytes(xml);
try
{
    webRequest = (HttpWebRequest)WebRequest.Create("http://" + this.host + ":" + this.port);
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.Method = "POST";
    webRequest.Timeout = 5000;
    webRequest.ContentLength = bytes.Length;
    using (Stream requeststream = webRequest.GetRequestStream())
    {
        requeststream.Write(bytes, 0, bytes.Length);
        requeststream.Close();
    }
    using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
    {
        using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
        {
            response = sr.ReadToEnd().Trim();
            sr.Close();
        }
        webResponse.Close();
    }
}
catch(Exception ex)
{
    MessageBox.Show(ex.ToString());
}
return response;
                Yes, this is pretty much expected http behaviour.
Options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With