Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET File Download messed up

Thread Tools

ASP.NET File Download messed up
Posts: n/a
I have a problem with file downloads. Here is the basic code:

sqlstring = "SELECT * FROM [File_Store] WHERE RecordID = " &
formatDBNumber(RecordID) & ";"
SQLDataSetObject = New DataSet("Image")
SQLAdapterObject = New SqlDataAdapter(sqlstring,
SQLCommandBuilderObject = New
SQLAdapterObject.Fill(SQLDataSetObject, "Table")

File_Name = SQLDataSetObject.Tables("Table").Rows(0)
File_Size = SQLDataSetObject.Tables("Table").Rows(0)
File_MimeType = SQLDataSetObject.Tables("Table").Rows(0)
Dim File_Binary(File_Size) As Byte
File_Binary = SQLDataSetObject.Tables("Table").Rows(0)

response.ContentType = File_MimeType
response.OutputStream.Write(File_Binary, 0,
Catch ex As Exception
End Try

This works when I have certain types of files in the database (like
PDF files). However, if the mime type is "application/"
for an XLS file, or a word doc, the file comes out as garbage in the
browser window instead of being recognized as a document of the
appropriate mime type.

Using a packet sniffer, I discovered that ASP.NET is inexplicable
appending a ton of spaces and "; charset=utf-8" at the end of my mime
type. I can verify that this text is not in my variable
(File_MimeType) above, nor in the database field where that variable
is read from.

I believe that this insertion is screwing up my file transfer.

The aspx file has no HTML in it at all, but has a reference to the
code file
"<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="File.aspx.vb" Inherits="FPA_AFE.File" %>"

There are no other response commands in my code anywhere. The IIS
server is set to enable buffering.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jar file is messed up? None other Gurjot General Computer Support 0 08-18-2011 04:04 AM
Messed with file security, now "access denied", how to recover? Philipp Schumann Computer Support 3 10-09-2005 08:35 PM
Ie font messed up after using s .css file in my app. Jensen bredal ASP .Net 4 03-21-2005 01:01 AM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM