VB脚本导致IIS崩溃

时间:2015-12-15 17:25:03

标签: iis vbscript asp-classic

我在ASP页面上有一个VBscript,它从SQL数据库创建一个PDF文件,但由于某种原因,它会在一段时间后或在几个用户同时使用它之后崩溃IIS。

以下是ASP页面的代码:

<%@ Language=VBScript %>

<%
    on error resume next

    Function ReadBinaryFile(FileName)
        Const adTypeBinary = 1

        'Create Stream object
        Dim BinaryStream
        Set BinaryStream = CreateObject("ADODB.Stream")

        'Specify stream type - we want To get binary data.
        BinaryStream.Type = adTypeBinary       

        'Open the stream
        BinaryStream.Open       

        'Load the file data from disk To stream object
        BinaryStream.LoadFromFile FileName       

        'Open the stream And get binary data from the object
        ReadBinaryFile = BinaryStream.Read

        'Close stream
        BinaryStream.Close
        set BinaryStream = nothing  

        If Err.Number <> 0 Then
        Response.Write "Error: " & Err.Number
        Response.Write "Error (Hex): " & Hex(Err.Number)
        Response.Write "Source: " &  Err.Source
        Response.Write "Description: " &  Err.Description
        Response.End
        End If

    End Function 


    Response.Buffer = true
    Response.Expires = 0
    Response.CacheControl = "no-cache"

    Tipo = Request.QueryString("Tabla")
    Folio = Request.QueryString("Documento")

    sPath = server.MapPath("/ecommerce/download")
    sName = "" & Tipo & "_" & replace(Folio,"-","_") & ".pdf"

    sFile = sPath & "\" & sName

    sFormato = Session("Var").GetValor(cstr("FTO_IMP_" & Tipo & ""),0)

    if sFormato = "" then   
        Response.Write "DEBE CONFIGURAR UN FORMATO DE IMPRESION, VARIABLE FTO_IMP_'" & Tipo & "' "
        Response.End
    end if

    aValor = split(sFormato,",")

    If aValor(0) = "" then  
        Response.Write "DEBE CONFIGURAR UN FORMATO DE IMPRESION, VARIABLE FTO_IMP_'" & Tipo & "'"
        Response.End
    End If

    If  Tipo = "FACTURA" then
        sValor = aValor(0)
    Else
        sValor = aValor(1)
    End if

    Session("Var").Memoria = sPath
    Set Pr = Server.CreateObject("impresionPRO.Impresion")  
    Pr.Imprimir_Formato cstr(sValor),cstr(Folio),cstr("PDF"),true,true,cstr(sFile)
    Set Pr = Nothing

        If Err.Number <> 0 Then
        Response.Write "Error: " & Err.Number
        Response.Write "Error (Hex): " & Hex(Err.Number)
        Response.Write "Source: " &  Err.Source
        Response.Write "Description: " &  Err.Description
        Response.End
        End If

    Dim vntStream

    vntStream = ReadBinaryFile(sFile)

    response.ContentType = "application/octet-stream"
    Response.AddHeader "Content-Disposition", "attachment; filename=" & sName
    Response.BinaryWrite(vntStream)
    Set oMyObject = Nothing
    Set vntStream = Nothing

        If Err.Number <> 0 Then
        Response.Write "Error: " & Err.Number
        Response.Write "Error (Hex): " & Hex(Err.Number)
        Response.Write "Source: " &  Err.Source
        Response.Write "Description: " &  Err.Description
        Response.End
        End If

    Response.End

活动viwer显示以下内容:

  

应用程序错误名称:w3wp.exe,版本:8.5.9600.16384,时间戳:0x52157ba0

     

错误模块名称:MSVBVM60.DLL版本:6.0.98.32,时间戳:0x4eb1c425

     

异常代码:0xc0000005

     

位移错误:0x0003ae9a

     

有错误的进程的ID:0x1360

     

应用程序错误的开始时间:0x01d1375392dc3524

     

应用程序错误的路径:C:\ Windows \ SysWOW64 \ inetsrv \ w3wp.exe

     

包含错误的路径模块:C:\ Windows \ System32 \ MSVBVM60.DLL

     

报告编号:0f2a7a3c-A34E-11e5-8119-000c2964cc30

     

包含错误的完整包名称:

     

包含错误的相对标识符应用程序包:

0 个答案:

没有答案