简体   繁体   中英

c# HttpWebRequest.GetResponse() returned an error: (404) Not Found

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"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM