Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Download text file

Reply
Thread Tools

Download text file

 
 
Samuel
Guest
Posts: n/a
 
      06-14-2007

Hi

I want to offer people to actually download text file and not view it on
browser (which is what happens by default)

Thank you,
Samuel


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      06-14-2007
You can force the download control by using :
http://support.microsoft.com/kb/260519/en-us
(applies as well to ASP.NET)

Once thr header is written you can then use Response.WriteFile to stream the
file to the browser...

--
Patrice

"Samuel" <(E-Mail Removed)> a écrit dans le message de news:
ukZ4$(E-Mail Removed)...
>
> Hi
>
> I want to offer people to actually download text file and not view it on
> browser (which is what happens by default)
>
> Thank you,
> Samuel
>



 
Reply With Quote
 
 
 
 
Samuel
Guest
Posts: n/a
 
      06-15-2007
I added the following code:

Response.AddHeader("content-disposition", "attachment;
filename=FileName.txt")

Response.ClearContent()

Response.WriteFile("FileName.txt")

But I get mcuh more content than the text file

Thank you,
Samuel



"Patrice" <http://www.chez.com/scribe/> wrote in message
news:(E-Mail Removed)...
> You can force the download control by using :
> http://support.microsoft.com/kb/260519/en-us
> (applies as well to ASP.NET)
>
> Once thr header is written you can then use Response.WriteFile to stream
> the file to the browser...
>
> --
> Patrice
>
> "Samuel" <(E-Mail Removed)> a écrit dans le message de news:
> ukZ4$(E-Mail Removed)...
>>
>> Hi
>>
>> I want to offer people to actually download text file and not view it on
>> browser (which is what happens by default)
>>
>> Thank you,
>> Samuel
>>

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      06-15-2007
That is ? Make sure also to clear the markup etc.. Basically such a page
should return anything but your content (i.. you shouldn't return any HTML,
html code, master pages content etc...). Though it's likely better to clean
up these elements for clarity a quick way to check this would to use
Response.end to end the streaming once the file is trnasmitted.

If the content is no more there this is because your page renders other
things at a later time (such as HTML markup if you have still this in your
ASPX page).

--
Patrice

"Samuel" <(E-Mail Removed)> a écrit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)...
>I added the following code:
>
> Response.AddHeader("content-disposition", "attachment;
> filename=FileName.txt")
>
> Response.ClearContent()
>
> Response.WriteFile("FileName.txt")
>
> But I get mcuh more content than the text file
>
> Thank you,
> Samuel
>
>
>
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:(E-Mail Removed)...
>> You can force the download control by using :
>> http://support.microsoft.com/kb/260519/en-us
>> (applies as well to ASP.NET)
>>
>> Once thr header is written you can then use Response.WriteFile to stream
>> the file to the browser...
>>
>> --
>> Patrice
>>
>> "Samuel" <(E-Mail Removed)> a écrit dans le message de news:
>> ukZ4$(E-Mail Removed)...
>>>
>>> Hi
>>>
>>> I want to offer people to actually download text file and not view it on
>>> browser (which is what happens by default)
>>>
>>> Thank you,
>>> Samuel
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

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
Forcing Download of File Appends HTML from Download Page to Downloaded File? Brett Kelly ASP .Net 1 06-16-2006 04:05 AM
problem with code download file - two window file download Sam -- ASP .Net 2 03-17-2005 04:20 PM
Re: How can I display a download link in my (C#) ASP.NET web form to download a file stored in my sql db? Steve C. Orr [MVP, MCSD] ASP .Net 0 03-07-2005 07:14 PM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM



Advertisments