PC Review


Reply
Thread Tools Rate Thread

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

 
 
~john
Guest
Posts: n/a
 
      4th Jan 2008
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.CommandArgument));
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
 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      4th Jan 2008
"~john" <(E-Mail Removed)> wrote in message
news:2622ad0f-c1e2-475e-aea6-(E-Mail Removed)...

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

 
Reply With Quote
 
~john
Guest
Posts: n/a
 
      4th Jan 2008

> 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





 
Reply With Quote
 
~john
Guest
Posts: n/a
 
      4th Jan 2008
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

 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      4th Jan 2008
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
>
>

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      4th Jan 2008
"~john" <(E-Mail Removed)> wrote in message
news:ca5c3003-4dfd-4dd9-acc7-(E-Mail Removed)...

> 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

 
Reply With Quote
 
~john
Guest
Posts: n/a
 
      4th Jan 2008
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Help Please: File Shares stop responding =?Utf-8?B?TGVz?= Windows XP Help 0 2nd Feb 2007 09:39 PM
Make MDE File Causes Access 2003 to Stop Responding JamesJ Microsoft Access Form Coding 3 14th Apr 2005 02:18 AM
File utilities stop responding =?Utf-8?B?TmVpbCBSb3llcw==?= Windows XP Help 2 17th Feb 2005 12:49 AM
A SQL Server database may stop responding when you run a transaction that affects many records Frank DeLuccia Microsoft Access ADP SQL Server 0 28th Jan 2004 08:16 PM
PowerPoint XP stop responding when I save my file Wizard Microsoft Powerpoint 1 19th Sep 2003 11:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:17 AM.