| 
 在开发ASP.NET网站后台管理系统时,我们可能会遇到这样的问题:上传大于4M的文件时,会提示错误: 错误信息如下:  1.异常详细信息:超过了最大请求长度。 2.引发异常的方法:Byte[] GetEntireRawContent() 3.堆栈跟踪:  at System.Web.HttpRequest.GetEntireRawContent() at  System.Web.HttpRequest.GetMultipartContent() at  System.Web.HttpRequest.FillInFormCollection() at  System.Web.HttpRequest.get_Form() at  System.Web.UI.Page.GetCollectionBasedOnMethod() at  System.Web.UI.Page.DeterminePostBackMode() at  System.Web.UI.Page.ProcessRequestMain() 
  哪怕我们在做上传程序是文件大小的判断加到了50M以上,还是会弹出上面的错误提示!给大家分析这个问题的根本所在和解决方法: 原因: Asp.net中,上传文件的默认大小是4096 KB,也就是4M,不过你可以在Web.config中更改这个数据。  
方法: 在web.config的授权节上写长度限制吧.maxRequestLength= "102400 " 这一句,单位为k (写在<system.web>中) 案例: <configuration>   
<system.web>   
<httpRuntime   executionTimeout= "9000"   maxRequestLength="502400"   useFullyQualifiedRedirectUrl= "false " minFreeThreads= "8 "   minLocalRequestFreeThreads= "4 "   appRequestQueueLimit= "100 "/>   
</system.web>  
</configuration>  
   
来自:http://www.wang0214.com/news/466.html  |