因用了NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误的解决方法
2011-12-28 15:03
495 查看
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://neatupload.codeplex.com/
但部署至项目后,有些地方用普通的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://neatupload.codeplex.com/
相关文章推荐
- 因用了NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误的解决方法
- 因用了NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误的解决方法
- 因用了NeatUpload大文件上传控件而导致Nonfile portion > 4194304 bytes错误的解决方法
- 关于64位CentOS上ptrace报<linux/user.h> no such file 错误的解决方法
- 使用kxml2-min-2.3.0.jar时的错误解决方法:Missing stack map in: <init> at label: 79
- 安装安卓->启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- Unity3D中中 rect[2] == rt->GetGLWidth() && rect[3] == rt->GetGLHeight()错误的原因及解决方法
- oracle安装后 tomcat启动报 Address already in use: JVM_Bind<null>:8080 错误 的几种解决方法
- <input type="file" name="filePath" />最简单的解决方法
- C中“fatal error C1075: end of file found before the left brace '{'”错误的几种可能解决方法
- intervention/image 2.4.0 requires ext-fileinfo * -> the requested PHP exte 错误解决方法
- 关于项目文件导入打开报:无法识别元素 <Target> 中的属性“Returns”错误解决方法
- [ios]The identity &#39;iPhone Developer&#39; doesn&#39;t match any valid, non-expired certifi错误解决方法
- Ruby on Rails安装过程中出现"no such file to load -- mkmf"错误的解决方法。
- Python默认编码错误SyntaxError: Non-ASCII character '\xe5'之解决方法
- android学习历程——“Unable to open log device '/dev/log/main': No such file or directory”错误解决方法
- httpxml.send->拒绝访问错误80070005的解决方法
- JSP 中使用<%@include%> 报 Duplicate local variable path 错误的解决方法
- VC6.0启动File->open和Project->add file to project崩溃的解决方法
- IE7下在DD DT中插入<a>元素导致样式跑偏的解决方法