解决大字段在Form中Post出错的方法
发布时间:2008-04-17 14:00:00
我们在使用很多新闻系统的时候,都会发现一个问题,尤其是使用 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解决问题的方法,现在新闻系统例如:乔客、动力、惠信比较好的系统也都存在这个问题,大家可以试着用这种方法来解决。


猜你喜欢
- groupby官方解释DataFrame.groupby(by=None, axis=0, level=None, as_index=Tru
- 远程连接SQL Server 2008,服务器端和客户端配置关键设置:第一步(SQL2005、SQL2008):开始-->程序--&g
- 前言在Python中变量名规则与其他大多数高级语言一样,都是受C语言影响的,另外变量名是大小写敏感的。Python是动态类型语言,也就是说不
- 条条框框的报表页面枯燥乏味?不妨给页面加点“新意”!前阵子,在看天气预报的时候,发现免费天气预报的调用代码,瞬间想到可以给我开发的报表“润润
- 备份多个数据库可以使用如下命令:mysqldump -uroot -p123456 --databases test1 test2 test
- 前言Golang 提供了database/sql包用于对SQL数据库的访问, 作为操作数据库的入口对象sql.DB, 主要为我们提供了两个重
- 主要用到requests和bf4两个库将获得的信息保存在d://hotsearch.txt下import requests;import b
- 如下所示:# 返回一个列表中第二大的数def second(ln):max = 0s = {}for i in range(len(ln))
- 本文实例为大家分享了Python深度优先算法生成迷宫,供大家参考,具体内容如下import random #warning: x and y
- 一、数据库远程管理技术 对于中小型应用,比如一个网站的建设和维护,这种大型应用平台就显得有些尾大不掉,开销也过于庞大。曾经在互联网技术和Ja
- 读写文件是最常见的IO操作。Python内置了读写文件的函数,用法和C是兼容的。读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由
- 我最近花了一些时间在探索CPython,并且我想要在这里分享我的一些冒险经历。Allison Kaptur的excellent guide
- 数据标准化是机器学习、数据挖掘中常用的一种方法。包括我自己在做深度学习方面的研究时,数据标准化是最基本的一个步骤。数据标准化主要是应对特征向
- 如果PyPi上搜html2text的话,找到的是另外一个库:Alir3z4/html2text。这个库是从aaronsw/html2text
- 修复Access数据库,我们一般使用微软Office 97中带的Access 97对数据库进行修复和整理。Access数据库被损坏分以下几种
- 将解压文件放置C盘配置环境变量 Patch:C:\mysql-5.7.25-winx64\bin;安装mysql切换到bin目录 cd C:
- 导语:除夕除夕,就是除去烦脑,迎接新的希望!在这里小编先祝大家除夕快乐,岁岁常欢笑,事事皆如意!正文:创建画布setup和draw是p5.j
- __add__(), 同一个类,两个对象相加的实现逻辑,重写 +class Myclass(object): &n
- 文中为大家分享了三种JavaScript判断对象是否为数组的方法,1. typeof首先我们会想到的是使用typeof来检测数据类型,但是对
- 本文实例为大家分享了Python3连接MySQL模拟转账的具体实现代码,供大家参考,具体内容如下# coding:utf8import sy