加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp-classic – Request.BinaryRead(Request.TotalBytes)抛出大

发布时间:2020-12-15 23:19:49 所属栏目:asp.Net 来源:网络整理
导读:我有代码通过POST接受二进制数据,并读入一个字节数组.对于大于200 Kb的文件,操作失败.我检查了我的系统管理员(我们正在运行IIS 7),看看我们的配置是否有限制,他说没有,并怀疑这是一个代码的问题.这里有人有任何潜在的问题吗?这是我的代码: Public Sub Init
我有代码通过POST接受二进制数据,并读入一个字节数组.对于大于200 Kb的文件,操作失败.我检查了我的系统管理员(我们正在运行IIS 7),看看我们的配置是否有限制,他说没有,并怀疑这是一个代码的问题.这里有人有任何潜在的问题吗?这是我的代码:
Public Sub Initialize
  If Request.TotalBytes > 0 Then
    Dim binData
      binData = Request.BinaryRead(Request.TotalBytes) ' This line fails'
      getData binData
  End If
End Sub


 Private Sub getData(rawData)
    Dim separator 
      separator = MidB(rawData,1,InstrB(1,rawData,ChrB(13)) - 1)

    Dim lenSeparator
      lenSeparator = LenB(separator)

    Dim currentPos
      currentPos = 1
    Dim inStrByte
      inStrByte = 1
    Dim value,mValue
    Dim tempValue
      tempValue = ""

    While inStrByte > 0
      inStrByte = InStrB(currentPos,separator)
      mValue = inStrByte - currentPos

      If mValue > 1 Then
        value = MidB(rawData,currentPos,mValue)

        Dim begPos,endPos,midValue,nValue
        Dim intDict
          Set intDict = Server.CreateObject("Scripting.Dictionary")

          begPos = 1 + InStrB(1,value,ChrB(34))
          endPos = InStrB(begPos + 1,ChrB(34))
          nValue = endPos

        Dim nameN
          nameN = MidB(value,begPos,endPos - begPos)

        Dim nameValue,isValid
          isValid = True

          If InStrB(1,stringToByte("Content-Type")) > 1 Then

            begPos = 1 + InStrB(endPos + 1,ChrB(34))
            endPos = InStrB(begPos + 1,ChrB(34))

            If endPos = 0 Then
              endPos = begPos + 1
              isValid = False
            End If

            midValue = MidB(value,endPos - begPos)
              intDict.Add "FileName",trim(byteToString(midValue))

          begPos = 14 + InStrB(endPos + 1,stringToByte("Content-Type:"))
          endPos = InStrB(begPos,ChrB(13))

            midValue = MidB(value,endPos - begPos)
              intDict.Add "ContentType",trim(byteToString(midValue))

            begPos = endPos + 4
            endPos = LenB(value)

            nameValue = MidB(value,((endPos - begPos) - 1))
          Else
            nameValue = trim(byteToString(MidB(value,nValue + 5)))
          End If

          If isValid = True Then

            intDict.Add "Value",nameValue
            intDict.Add "Name",nameN

            dict.Add byteToString(nameN),intDict
          End If
      End If

      currentPos = lenSeparator + inStrByte
    Wend
  End Sub

以下是日志中出现的错误:

Log Name:      Application    
Source:        Active Server Pages    
Date:          11/11/2010 2:15:35 PM    
Event ID:      5    
Task Category: None    
Level:         Error    
Keywords:      Classic    
User:          N/A    
Computer:      xxxxx.xxxxx.xxx    
Description:    
Error: File /path-to-file/loader.asp Line 36 Operation not Allowed. .    
Event Xml:    
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">    
  <System>    
    <Provider Name="Active Server Pages" />    
    <EventID Qualifiers="49152">5</EventID>    
    <Level>2</Level>    
    <Task>0</Task>    
    <Keywords>0x80000000000000</Keywords>    
    <TimeCreated SystemTime="2010-11-11T19:15:35.000Z" />    
    <EventRecordID>19323</EventRecordID>    
    <Channel>Application</Channel>    
    <Computer>PHSWEB524.partners.org</Computer>    
    <Security />    
  </System>    
  <EventData>    
    <Data>File /mghdev/loader.asp Line 36 Operation not Allowed. </Data>    
  </EventData>    
</Event>

解决方法

默认情况下,POST请求中的实体大小的限制为200K,因此您的错误.

您可以增加该限制打开IIS管理器并将树导向到您的应用程序.双击主面板中的“ASP”图标.展开“限制”类别.将“最大请求实体限制”修改为更大的值.

如果这是一个公共网站,小心您设置的限制,限制的目的是防止恶意POSTs压倒网站.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读