Download text file

  • Thread starter Thread starter Samuel
  • Start date Start date
S

Samuel

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
 
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
 
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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Compress jpg 3
Download of a file question 5
Time out of page response 2
Browsers for ASP.NET 1
Login Cookie 4
Traffic Source 2
Use Image as a button 2
Image alignment problem 1

Back
Top