您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

学习ASP之解决大字段在Form中Post出错的方法

来源:网络整理 责任编辑:栏目编辑 发表时间:2013-07-01 21:19 点击:
 我们在使用很多新闻系统的时候,都会发现一个问题,尤其是使用 HtmlEdit 从WORD文档中直接拷贝文章(尤其里面有复杂表格和文字)的时候,提交会有一个错误发生。

"Request Object, ASP 0107 (0x80004005)"

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

程序出错提示总是在 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),第二种使用分段上传的方式,基于少更改程序的
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • WAP常见问题问答大全(四)
    • ASP开发必备:WEB打印代码大全
    • ASP调用系统ping命令
    • asp缓存技术
    • ASP教程:第三篇 ASP基础
    • 用ASP+XML打造留言本(4)
    • 关于ASP Recordset 分页出现负数解决方法及建议
    • 用asp怎样编写文档搜索页面(5)
    • ASP处理多关键词查询实例代码
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1