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