Download files from SQL failing

Discussion in 'Classic ASP' started by bill wolf, Dec 27, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I just signed up for a DiscountASP account and the following snippet worked on my old host.

    The purpose of the script is to extract binary data from my SQL 08 DB and display a file download dialog to save or open. IE8 is spitting out the generic "IE cannot display the webpage" error.

    Code:
    <!--#include file="includes/data.asp"-->
    <%
    If Session("LoginID") <> "" Then
        SQL = "SELECT * FROM dbo.GELeaseFileDocuments where dbo.GELeaseFileDocuments.DocumentID = " & Request.QueryString("id")
        rs.open sql, cn, 3, 1
    
        Response.ContentType = "application/octet-stream"
        ' let the browser know the file name
        Response.AddHeader "Content-Disposition", "attachment;filename=" & Trim(rs("DocumentName"))
        ' let the browser know the file size
        Response.AddHeader "Content-Length", rs("FileSize")
        Response.BinaryWrite rs("Document")
        rs.close
    Else
        Response.write ("Download Failed.")
    End If
    %>
     
  2. Self-resolved

    Resolution: commented out content length.

     
  3. Wow, good job, I would have missed that. ;-)
     
  4. Thanks.

    There's no rush like frantic testing and debugging during a migration.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page