I have an Asp.net console application and i use this code for upload file:
byte[] buffer = memoryStream.ToArray();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = "application/octet-stream";
request.Method = "POST";
request.ContentLength = buffer.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(buffer, 0, buffer.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
If the buffer size 8 MB the HttpWebResponse work perfect but if the buffer size 32 MB the request.GetResponse() returned an error:
The remote server returned an error: (404) Not Found.
I guess the url that you try to request has max Request Length and not allow for large Length for Request.
the modify should be in the destination service or the url. the modify on config file on :
<httpRuntime maxRequestLength="33554432" executionTimeout="300"/>