473,320 Members | 2,109 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,320 software developers and data experts.

Downloading file from database causes page to stop responding???

I have binary files stored in a SQL Server table that I want the user
to be able to download from an aspx webpage. The files are displayed
on the form as "LinkButtons". When the link is clicked the code in my
event handler writes out the contents of the file which prompts the
user for the download or open dialog box. The first time you click an
attachment it opens fine but any action on the page after that doesn't
seem to work, the page just stops responding. Trying to click other
attachments do not open and clicking Buttons stop responding. Below is
my EvenHandler... any idea what I'm doing wrong? Should I not be doing
this in an event handler?


1 void LinkButton_Download_Command(object sender, CommandEventArgs
e)
2
3 {
4
5 DBFile f =
DBFile_DAL.GetByID(Convert.ToInt32(e.CommandArgume nt));
6
7
8 Page.Response.AppendHeader("Content-Disposition",
"Attachment; Filename=" + f.FileName);
9
10 Page.Response.ContentType = "application/download";
11
12 Page.Response.BinaryWrite(f.FileData);
13
14 }
15
16
Jan 4 '08 #1
6 1970
"~john" <So********@gmail.comwrote in message
news:26**********************************@l32g2000 hse.googlegroups.com...

10 Page.Response.ContentType = "application/download";
11 Page.Response.Flush();
12 Page.Response.BinaryWrite(f.FileData);
13 Page.Response.End();
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 4 '08 #2
10 * *Page.Response.ContentType = "application/download";
11 * *Page.Response.Flush();
12 * *Page.Response.BinaryWrite(f.FileData);
13 * *Page.Response.End();

I just tried that and got this output in IE.


The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and
then click the Refresh button, or try again later.

--------------------------------------------------------------------------------

An invalid character was found in text content. Error processing
resource 'http://greenstapler/iso/ems/Pages/CarParForm.asp...

GIF89a

Jan 4 '08 #3
Also I'm doing this in an event handler of the same web page. Do I
need to redirect to another web page to handle the download?

John

Jan 4 '08 #4
From what you describe, it would be a lot cleaner and less error-prone to
have the download appear in a separate window that can then be closed,
allowing the user to continue operating in the original page.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"~john" wrote:
Also I'm doing this in an event handler of the same web page. Do I
need to redirect to another web page to handle the download?

John

Jan 4 '08 #5
"~john" <So********@gmail.comwrote in message
news:ca**********************************@p69g2000 hsa.googlegroups.com...
Also I'm doing this in an event handler of the same web page. Do I
need to redirect to another web page to handle the download?
That would certainly be my preferred way of doing it, yes...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 4 '08 #6
Thanks everyone... Also, I should mention this code is inside a
SharePoint 2007 WebPart. When copying the same code over to a regular
ASP.net webpage it appears to work fine. I'm not sure why SharePoint
would treat it differently.

John

Jan 4 '08 #7

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

Similar topics

5
by: John Lauwers | last post by:
Hi, Can I download a file automatically from internet, Just type the internet adress in a textbox and in another textbox the pad where it will be saved and then push a button so the downloaded...
6
by: Tony K | last post by:
I have the most peculiar problem with an ASP.NET page which we use for downloading a file. When the user clicks on a link, the link points to an ASPX page which downloads the file selected. ...
6
by: Henke | last post by:
I have a web application that is used to transfer files to and from a database. The files are streamed and stored in the database that is. From one page I can download the files to the client, by...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
5
by: Trapulo | last post by:
Hi, I've a big trouble with an asp.net page. Basically, the page has an swf that starts and downloads some data from an other asp.net page. The application works well on my testing IIS 6, but...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
4
by: PiotrKolodziej | last post by:
hi I have a thread that downloades a file. Problem is : Not all files are beeing downloaded. I observed that only the small files are beeing downloaded correctly. I also cant download two files...
7
by: raids51 | last post by:
Hello, i have a program that downloads a file using the httpwebrequest/response, and it usually works, but sometimes it will freeze at a random part of the download without an error. here is the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.