使用 HTML5 文件 API 的 IIS7 对于大文件返回 404
我正在尝试按照此示例实现用于图像上传的文件 API
http://robertnyman .com/html5/fileapi-upload/fileapi-upload.html
在服务器端,我使用 ASP.NET MVC 3 和 IIS7(集成,仅限 32 位),
一切都可以在本地与开发正常工作服务器和IIS7.5。在服务器上它也可以工作,除了如果文件具有一定大小(使用 2.2MB 图像文件),上传似乎可以工作,但响应是 404 页面。我已将 maxRequestLength 配置为 10MB,但即使使用默认的 4MB,它也应该可以工作。
我返回的404页面是IIS7默认的404,而不是我的应用程序的404页面(通过在Fiddler或Firebug中查看结果)。我捕获所有随机 URL 并显示自定义 404 页面,但在本例中,请求似乎未发送到 ASP.NET 管道(应用程序池设置为“集成”)。
我还记录了可能发生的任何异常(包括 404)——就这个问题而言,日志是清晰的。服务器的事件日志中也没有任何内容。
有什么想法吗?
谢谢!
I'm trying to implement File API for image uploading following this example
http://robertnyman.com/html5/fileapi-upload/fileapi-upload.html
On the server side I'm using ASP.NET MVC 3 with IIS7 (integrated, 32 bit only)
Everything works fine locally with Development Server and IIS7.5. On the server it also works, except that if a file is of a certain size (working with a 2.2MB image file) the upload seems to be working but the response is a 404 page. I've configured the maxRequestLength to be 10MB, but even with the default 4MB it should have worked.
The 404 page I get back is the IIS7 by default 404, not my application's 404 page (by looking at the result in Fiddler or Firebug). I'm catching all random URLs and displaying a custom 404 page, but in this case it seems like the request is not sent to the ASP.NET pipeline (the Application Pool is set to Integrated).
I'm also logging any exception that may occur (including 404s) -- the log is clear as far as this problem. There's nothing in the server's event log either.
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它与 HTML5 File API 或 ASP.NET MVC 无关。
问题是在 IIS7 中您必须指定 maxAllowedContentLength。宣传的默认值为 4MB,但实际情况似乎并非如此,因为上传 2MB 文件失败。有趣的是,本地 IIS7.5 (Windows 7) 似乎没有这个问题 - 也许它已在 IIS7.5 (Windows Server 2008 R2) 中修复。
要修复它,请在您的 web.config 中确保您有类似的内容:
值以字节为单位;我指定了10MB
It had nothing to do with HTML5 File API or ASP.NET MVC.
The problem was that in IIS7 you have to specify the maxAllowedContentLength. The advertised default value is 4MB, but this doesn't seem to be the case since uploading a 2MB file failed. Interestingly, the local IIS7.5 (Windows 7) doesn't seem to have this problem -- maybe it's fixed in IIS7.5 (Windows Server 2008 R2)
To fix it, in your web.config make sure you have something like this:
The value is in bytes; I specified 10MB