473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ASP.NET File Download messed up

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,
SQLConnectionObject)
SQLCommandBuilderObject = New
SqlCommandBuilder(SQLAdapterObject)
SQLAdapterObject.Fill(SQLDataSetObject, "Table")

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

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

This works when I have certain types of files in the database (like
PDF files). However, if the mime type is "application/vnd.ms-excel"
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.

Apr 19 '07 #1
0 950

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Ken | last post by:
How do I download files from the internet server to my computer? How do I tell the script the correct hard drive folder on my computer to copy the files to? After connecting to the internet...
8
by: Tom | last post by:
Hi, I have a log file and of course I want to add the new information to the end of that log file. Unfortunately I always delete the old information and only append the current info. Right now...
3
by: Eric Lilja | last post by:
Hello, I'm creating a small utility for an online game. It involves parsing a text file of "tradesskill recipes" and inserting these recipes in a gui tree widget (similar to gui file browsers if...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
170
by: I_AM_DON_AND_YOU? | last post by:
Whether we can upload the projects (in .zip format) in these newsgroups? I am asking this because earlier there are more than 50 posts (in one thread) about this query and they are contradicting...
16
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
11
by: quagmireman | last post by:
I am very new to perl... today is my first encounter. and i think i messed up pretty big. I was trying to update some info on a website, so i thought I could just open the index.pl file and change...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.