显示meaningfull错误上传时,过大的文件 [英] Displaying a meaningfull error when uploading too large a file

查看:158
本文介绍了显示meaningfull错误上传时,过大的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们设置了固定的限制对我们网站上上传的文件大小 - 默认asp.net的规模以下和IIS设置

We have set a fixed limit on the filesize of uploads on our site - below the size of the default asp.net and iis setting.

我在的Application_BeginRequest一个简单的捕捉设置,捕捉这(它不是excat,因为它会检查CONTENTLENGTH包括所有其他形式的数据,但它不够好)。
我想要么继续处理页面的用户尝试上传至,或作为后备计划,将用户重定向到一个页面,并解释说,文件大小太大(我们已经有一个副标题解释这一点,但你知道用户 - 他们并不需要阅读没有臭字幕')

I have a simple catch setup in Application_BeginRequest that catches this (it's not excat since it checks the ContentLength including all other form data but it's good enough). I want to either resume processing of the page the user tried to upload to, or as a fallback plan redirect the user to a page, explaining that the filesize was too big (we already have a subtitle explaining this, but you know users - 'they don't need to read no stinking subtitles').

那么,有什么问题呢?那么看来,我的回答是已经发送给用户 - 404说明该页面无法找到。我不希望这种行为,我要刷新这个反应,因为它不是一个我希望用户看到的 - 我想告诉别的东西 - 建立自己的响应,重定向或只是过程中,他们理应得到的页面反正。

So what's the problem? Well it seems that my Response was already sent to the user - a 404 explaining that the page could not be found. I don't want this behaviour, i want to flush this response, since it's not the one i want the user to see - i want to show something else - build my own response, redirect or just process the page they were supposed to get anyways.

我认为这个问题可能仍在IIS拒绝请求/后因为文件比IIS想要什么大。我真的不挖这一点 - 一个疯狂的用户试图上传图片20meg不应允许拒绝服务IIS的瘫痪,但就是这个吗?还是我得到一个机会拦截此响应用户 - 而不是在IIS增加最大尺寸,从而在收到该文件花费的带宽,我只是想确定这个岗位作为'是太大了,并发送apropriate响应回给用户。

I think the problem might still be IIS rejecting the request/post since the file is bigger than what IIS wants. I really do dig this - a mad user trying to upload a 20meg picture shouldn't be allowed to DoS the IIS to its knees, but is this it? Or do i get a chance to intercept this response to the user - instead of increasing the max size on the IIS and thus spending bandwith on receiving this file, i just want to identify this post as 'being too big' and sending an apropriate response back to the user.

推荐答案

我有这个同样的问题,很多搜索后似乎有这个不完美的解决方案。你可以改变最大请求长度设置在这一点IIS将服务于ASP.Net错误。您还可以赶上在Global.asax的这个错误,并显示给用户更加业间友好的错误页面。

I had this same problem and after lots of searching there seems to be no perfect solution to this. You can change the Max Request Length to set at which point IIS will serve the ASP.Net error. You can also catch this error on global.asax and show the user a more freindly error page.

您在这里可以找到这样的 http://www.developer.com更多信息/db/article.php/10920_3426051_2

You can find more information on doing this here http://www.developer.com/db/article.php/10920_3426051_2

这篇关于显示meaningfull错误上传时,过大的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆