网络编程
位置:首页>> 网络编程>> Asp编程>> 解决大字段在Form中Post出错的方法

解决大字段在Form中Post出错的方法

  发布时间:2008-04-17 14:00:00 

标签:post,form,错误,微软

我们在使用很多新闻系统的时候,都会发现一个问题,尤其是使用 HtmlEdit 从WORD文档中直接拷贝文章(尤其里面有复杂表格和文字)的时候,提交会有一个错误发生。

"Request Object, ASP 0107 (0x80004005)"

很多编程人员都以为是 Access 数据库备注字段64kb限制的问题,开始 icech 也以为是,但是后来用了其他新闻系统的 SQL 版本,同样的问题发生了。因此我猜想,可能是浏览器的问题。但是 Form 表单使用的都是 Post 方式,应该和浏览器无关,那是什么原因呢?

相关文字推荐:WIN2003无法上传较大的文件Request对象错误解决方法

程序出错提示总是在 Request.Form(“xxx”)的地方,因此我判断,可能是Request有大小的限制。然后就去MSDN上查找“ASP 0107 (0x80004005)”,果然是Request的问题。微软的原文是这样的。

PRB: Error "Request Object, ASP 0107 (0x80004005)" When You Post a Form

The information in this article applies t

Microsoft Active Server Pages

This article was previously published under Q273482

SYMPTOMS

When you post a large form field in Microsoft Internet Information Services 5.0, you may receive the following error message:

Error Type:

Request object, ASP 0107 (0x80004005)

The data being processed is over the allowed limit.

When you post a large form field in Microsoft Internet Information Server 4.0, you may receive the following error message:

Request object error 'ASP 0107 : 80004005'

Stack Overflow

/projectname/page.asp, line XX

The data being processed is over the allowed limit.

CAUSE

The size limit of each form field that is retrieved in the Request object is 102,399 bytes. The error occurs when you exceed this limit.

RESOLUTION

To resolve this problem, use one of the following methods:

Instead of reading form variable values with the Request.Form collection, use Request.BinaryRead (Request.TotalBytes), and parse the form values from the output of Request.BinaryRead.

Use a File Upload scheme, such as Microsoft Posting Acceptor.

Break the HTML form variables into multiple form variables before you submit the form. The 102,399 byte limit is for each form variable, so you can have multiple form variables of 102,399 characters or less. The following sample code illustrates this: WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

<FORM method=post action=LargePost.asp name=theForm onsubmit="BreakItUp()">

<Textarea rows=3 cols=100 name=BigTextArea>A bunch of text...</Textarea>

<input type=submit value=go>

</form>

<SCRIPT Language=JavaScript>

function BreakItUp()

{

//Set the limit for field size.

var FormLimit = 102399

//Get the value of the large input object.

var TempVar = new String

TempVar = document.theForm.BigTextArea.value

//If the length of the object is greater than the limit, break it

//into multiple objects.

if (TempVar.length > FormLimit)

{

document.theForm.BigTextArea.value = TempVar.substr(0, FormLimit)

TempVar = TempVar.substr(FormLimit)

while (TempVar.length > 0)

{

var objTEXTAREA = document.createElement("TEXTAREA")

objTEXTAREA.name = "BigTextArea"

objTEXTAREA.value = TempVar.substr(0, FormLimit)

document.theForm.appendChild(objTEXTAREA)

TempVar = TempVar.substr(FormLimit)

}

}

}

</SCRIPT>

The receiving Active Server Page (ASP) page reconstructs the variable:

<%

Dim BigTextArea

For I = 1 To Request.Form("BigTextArea").Count

BigTextArea = BigTextArea & Request.Form("BigTextArea")(I)

Next

%>

100 K的限制?微软竟然来这一手!幸好他们自己给出了几个解决方案,看一下上文可以知道,微软提供了2种可行的方法:

第一种使用Request.BinaryRead (Request.TotalBytes),第二种使用分段上传的方式,基于少更改程序的原则,我们采用第二种方式。但是在使用的过程中,icech无意中发现,直接使用

For I = 1 To Request.Form("BigTextArea").Count

BigTextArea = BigTextArea & Request.Form("BigTextArea")(I)

Next

来代替Request.Form("BigTextArea")竟然也能达到同样的效果!惊奇!我想可能系统每次将100K的内容发送给Request,上段程序又在进行循环,因此达到了同样的效果。

以上是icech解决问题的方法,现在新闻系统例如:乔客、动力、惠信比较好的系统也都存在这个问题,大家可以试着用这种方法来解决。

0
投稿

猜你喜欢

  • SQL Server TEXT、NTEXT字段拆分的问题引用的内容:SET NOCOUNT ON CREATE 
  • 今天看YUI的视频教程,YUI的工程师介绍的一款在线的图片压缩工具,也许你用过,也许没有,不过我这里强烈推荐大家用一下,我用smush.it
  • 如果你细心跟踪一下SQL Server数据库服务器的登录过程,你会发现口令计算其实是非常脆弱的,SQL Server数据库的口令脆弱体现两方
  • Monster是Alipay UED推出的网站代码分析、质量检测及评分的浏览器扩展,它能智能分析CSS、JS、HTML内容并生动形象展示网页
  • QL Server事件探查器(Profiler)可以帮助数据库管理员跟踪SQL Server数据库所执行的特定事件,监视数据库的行为;并将这
  • 什么是Canvas<canvas> 是一个新的 HTML 元素,这个元素在 HTML5&
  • 本文是关于人物角色的一些简单介绍,感谢瑶芝同学提供的大力帮助!    人物角色(Personas)作为一种技术
  • 前段时间嗷嗷有发过"好玩的放大镜效果",今天看了下,发现还有简单的方法也能够实现,即利用内外补丁的调整。有兴趣的可以在琢
  • 大多的MySQL都是装在Linux上的,而我们的本机上一般都会装MySQL-Front.那如何用MySQL-Front连接远端Linux系统
  • 我们经常会遇到多重查询问题,而长长的SQL语句往往让人丈二和尚摸不着头脑。特别是客户端部分填入查询条件时,如用普通方法将更是难上加难。以下巧
  • Java一直标榜一句老话叫“编写一次,到处运行(Write Once,Run Anywhere)”,CSS也差一点点做到了。但就是为了差的一
  • “你如何为成千上万的用户和页面提供CSS?” 这是Nicole Sullivan在她的在丹佛的Web Directions North 大会
  • <style> body {margin:10px;background-color:#ffffff;margin-t
  • 昨天打包下载了一个服务器整站,拿到这个*.mdb的文件后,却不知道怎么用,百度了一下,才知道是一种木马打包的形式文件,不能用WINrar来解
  • 某些情况下:我们希望在一个SQL Server下访问另一个sqlserver数据库上的数据,或者访问其他oracle数据库上的数据,要想完成
  • 如何在线创建新表?下面我们以建立一个数码相机库用表为例,看看在ASP程序代码中使用 [CREATE TABLE 相机 (品牌 TEXT(10
  • “网页设计三剑客”可能很多新同学都没听说过,因为缔造神话的公司已经快销声匿迹。“网页设计三剑客”是Macromedia公司旗下Dreamwe
  • 1.通过工具"DTS"的设计器进行导入或者导出DTS的设计器功能强大,支持多任务,也是可视化界面,容易操作,但知道的人一
  • js浮点数计算有时是不准确的,比如7*0.8 == 7*8/10的值为false,因为7*0.8=5.6000000000000005,乘出
  • 1,FCKeditor 编辑器最新版本: 2.3.1站点:http://www.fckeditor.net 演示:http://w
手机版 网络编程 asp之家 www.aspxhome.com