问题描述
我有一个 Web 服务,它接受一个字节 [] 并保存它.
I have a web service that takes a byte[] and saves it.
这适用于小"文件,但是一旦我达到一定大小,Web 服务就会失败并返回请求失败,HTTP 状态为 404:未找到."
This works fine for "small" files, but once I hit a certain size the web service fails and returns "The request failed with HTTP status 404: Not Found."
据我所知,这似乎是一个 IIS 设置,它限制了可以发布的文件的大小(以防止拒绝服务攻击).我试图增加该设置,但我无法确定什么设置以及在哪里/如何设置它.我使用的是 IIS7,而网络服务是在 .net (asmx) 中完成的.
From what I've seen this appears to be an IIS setting that limits the size of a file that can be posted (to prevent Denial of Service attacks). I've tried to increase that setting, but I am having trouble determining what setting and where/how one would set it. I am using IIS7 and the webservice is done in .net (asmx).
在web服务的web.config中我添加了以下内容(这似乎增加了可以接受的文件大小,但不是一直到这个设置大小)
In the web.config of the web service I have added the following (which seemed to increase the size of file that can be accepted, but not all the way to this setting size)
<system.web>
<httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
...
</system.web>
有关在何处(以及如何)增加文件大小的任何建议,我们将不胜感激.
Any suggestions on where (and how) to increase the size of file that the web service would be greatly appreciated.
推荐答案
除了问题中提到的 httpRuntime/maxRequestLength 之外,貌似还有一项可以添加到 web 服务的 web.config 文件中允许传输大文件.
In addition to the httpRuntime/maxRequestLength mentioned in the question, it looks like there is an additional item that can be added to the web service's web.config file to permit large file transfers.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000" />
</requestFiltering>
</security>
</system.webServer>
这似乎允许通过网络服务上传更大的文件.
This appears to enable larger files to be uploaded via web services.
这篇关于如何将大文件(> 25MB)上传到 Web 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!