AsyncFileUpload:如何隐藏的最大请求长度超过警戒错误? [英] AsyncFileUpload: How do I hide the max request length exceeded alert error?

查看:584
本文介绍了AsyncFileUpload:如何隐藏的最大请求长度超过警戒错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我上传的文件比CONFIGS最大请求长度,我得到一个更大的服务器响应错误:未知的服务器错误警报弹出。它问我是否想看到的响应页面,如果我点击确定应用程序错误窗口弹出说最大请求长度超过了。

If I upload a file that is larger than the configs max request length I get a "Server Response Error: Unknown Server Error" alert popup. It asks if I want to see the response page and if I click "OK" an application error window pops up saying "Maximum request length exceeded."

我发现这已经...
<一href=\"http://stackoverflow.com/questions/665453/catching-maximum-request-length-exceeded\">http://stackoverflow.com/questions/665453/catching-maximum-request-length-exceeded

我是在得到那个工作是不成功的。

I was unsuccessful at getting that to work.

我还发现了另外一个问题,SO(我似乎现在不能找到它),这是类似的。所不同的是,OP问如何重定向到一个错误页面。我不想这样做。答案是使用自定义错误重定向,获取设置在web.config中。

I also found another SO question (I can't seem to find it now) that was similar. The difference was that the OP had asked how to redirect to an error page. I don't want to do that. The answer was to use a custom error redirect that gets setup in the web.config.

我只是想吸收的错误,什么也不做,我使用的是OnClientUploadError事件通过JS来处理错误。基本上,我只是不想让这个愚蠢的弹出消息。

I simply want to absorb the error and do nothing, I'm using the OnClientUploadError event to handle the error via js. Basically, I just don't want this stupid popup message.

一个奇怪的是,在本地运行应用程序时,我没有看到错误,但我确实看到了错误,当我已经得到了应用程序部署到我们的服务器。

One odd thing is that I don't see the error when running the app locally, but I do see the error when I've got the app deployed out to our server.

注意我应该提到,我知道的配置值来设置最大请求长度。设置它是非常大的不会为这种情况下工作。

Note I should have mentioned that I know about the config value to set the max request length. Setting it to be very large won't work for this instance.

更新所以,我想知道,如果这可能是一些与我们的服务器的IIS设置。这是奇怪的是,它不会在本地发生。什么,我应该寻找什么想法?大部分是我在网络上找到建议修改Machine.config。然而,正如我之前说的,我不只是想起来允许的大小。我通过处理JS错误精,我不希望此警报在任何情况下显示出来。

Update So, I'm wondering if this could be something with the IIS settings of our server. It's odd that it doesn't happen locally. Any ideas of what I should be looking for? Most of what I find on the net suggests modifying the machine.config. However, as I said before, I don't simply want to up the allowed size. I am handling the error fine via js, I don't want this alert to show up under any circumstances.

更新嗯,这听起来像IIS默认限制为30MB。我想要的文件是比这少得多。我不知所措......

Update Well, it sounds like the IIS default limit is 30MB. The files I'm trying are much less than this. I'm at a loss...

推荐答案

在OnClientUploadError写javascript将设置一些标志,然后可以在提交表单给用户上载引起的错误消息中使用该标志。

On the OnClientUploadError write javascript which will set some flag and then that flag can be used while submitting the form giving the user the message that the upload caused error.

<asp:AsyncFileUpload ID="fileUpload" 
                     runat="server" OnClientUploadError="onUploadError"
                     OnClientUploadComplete="uploadComplete"
                     OnUploadedComplete="OnUploadComplete" />

在JavaScript

in javascript

 <script language="javascript" type="text/javascript">
     var uploadError = false;    
     function onUploadError()
     {
          uploadError = true;
     }

     function uploadComplete()
     {
          uploadError = false;
     }

     function validateForm()
     {
         return !uploadError;
     }
 </script>

通过这种重定向错误页面是可以避免的。

By doing this redirection to error page is avoided.

这篇关于AsyncFileUpload:如何隐藏的最大请求长度超过警戒错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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