[英]c# HttpWebRequest.GetResponse() returned an error: (404) Not Found
I have an Asp.net console application and i use this code for upload file: 我有一个Asp.net控制台应用程序,我使用以下代码上传文件:
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: 如果缓冲区大小为8 MB,则HttpWebResponse可以正常工作,但是如果缓冲区大小为32 MB,则request.GetResponse()返回错误:
The remote server returned an error: (404) Not Found.
远程服务器返回错误:(404)找不到。
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. 修改应该在目标服务或URL中。 the modify on config file on :
修改配置文件:
<httpRuntime maxRequestLength="33554432" executionTimeout="300"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.