• 因用了NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误的解决方法


    今天遇到一个问题,就是“NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误”,百度后发现了一个解决方法,跟大家分享下:

    NeatUpload是一个开源的大文件上传控件,非常的强大,支持文件类型过滤、上传进度条显示、多文件上传等强大的功能。 

             但部署至项目后,有些地方用普通的FileUpload上传时却发生了一个错误(Nonfile portion > 4194304 bytes,文件大于默认值4M),因如果用NeatUpload控件及需要显示上传进度条的话,得在web.config中加入如下代码:

                  <httpModules>
                           <add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule, Brettle.Web.NeatUpload"/>

                 </httpModules> 

            这时全站都会默认使用此httpModule,当你使用FileUpload上传文件时,只要是超过4M(默认的)的都不能上传,就算你配置了<httpRuntime maxRequestLength="400000" executionTimeout="3600"/>都没用,还是会出现Nonfile portion > 4194304 bytes的错误的。 

            解决方法如下:

            1、在<configuration>里面加入以下代码:

                    <configSections>
                               <sectionGroup name="system.web">
                                        <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" allowLocation="true" />
                               </sectionGroup>
                    </configSections>

     

            2、在<system.web>节中插入以下代码(此方式是全局性的,第3种为针对某页面):

                   <neatUpload useHttpModule="true" maxNormalRequestLength="40960" maxRequestLength="2097151" defaultProvider="FilesystemUploadStorageProvider">
                            <providers>
                                  <add name="FilesystemUploadStorageProvider" type="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload"/>
                           </providers>
                  </neatUpload>

                  此方法是修改属性maxNormalRequestLength的值为40960(40M),如果将useHttpModule改为false则无所谓。

     

           3、在<configuration>里面的后面位置加入以下代码(此方式是针对某一页面):

                    <location path="UploadFile.aspx" ><!--上传文件的页面路径-->
                           <system.web>
                                  <neatUpload useHttpModule="true" />  <!--为true则代表使用neatUpload的httpModule,false为不使用-->
                                  <httpRuntime maxRequestLength="40960" executionTimeout="3600" useFullyQualifiedRedirectUrl="true" />  <!--允许最大为40M-->
                          </system.web>
                   </location>

     

           neatUpload节点的相关属性介绍如下: 

             <neatUpload 
                  useHttpModule="true or false, defaults to true"
                  maxNormalRequestLength="up to 2097151 in KBytes, defaults to 4096" 
                  maxRequestLength="up to 2097151 in KBytes, defaults to 2097151" 
                  maxUploadRate="rate in KBytes/sec, defaults to -1 which means unlimited"
                  postBackIDQueryParam="parameter name, defaults to NeatUpload_PostBackID"
                  multiRequestUploadHandlerUrl="URL that handles the requests in a multi-request upload,defaults to ~/NeatUpload/MultiRequestUploadHandler.ashx"
                  debugDirectory="directory to which debug info should be written, defaults to none"
                  decryption="name of the SymmetricAlgorithm to use to encrypt/decrypt protected data, defaults to .NET default algorithm used by SymmetricAlgorithm.Create()"
                  validation="name of the HashAlgorithm to use to validate protected data, defaults to .NET default algorithm used by HashAlgorithm.Create()"
                  decryptionKey="32 hex-digit key used to encrypt/decrypt protected data, defaults to auto-generated for each app instance"
                  stateMergeIntervalSeconds="secs between merges of the current and stored upload states,defaults to 1"
                  stateStaleAfterSeconds="secs before an unchanged upload state can be removed from the store, defaults to 60"
                  defaultStorageProvider="friendly name,defaults to a FilesystemUploadStorageProvider with default temp dir"
                  defaultStateStoreProvider="friendly name, defaults to a AdaptiveUploadStateStoreProvider"
            >
                  <providers>
                       <add name="friendly name"  type="type derived from Brettle.Web.NeatUpload.UploadStorageProvider" />
                 </providers>
         </neatUpload>

     本来来自:http://blog.csdn.net/fgdfgasd/article/details/7108973 

    分享给遇到同样问题的朋友。

  • 相关阅读:
    HDU 5412 CRB and Queries 动态整体二分
    POJ 2104 K-th Number
    【模板】可持久化线段树(主席树)
    【AHOI2005】病毒检测
    【HNOI2004】L语言
    P1837 单人纸牌_NOI导刊2011提高(04)
    【USACO15FEB】审查(黄金)Censoring (Gold)
    【USACO12JAN】视频游戏的连击Video Game Combos
    专访阿里云资深技术专家黄省江:中国SaaS公司的成功之路
    干货来了!2019阿里云合作伙伴峰会SaaS加速器专场回顾合集:嘉宾分享、深度解读
  • 原文地址:https://www.cnblogs.com/qtqq/p/3760858.html
Copyright © 2020-2023  润新知