Download text file

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
 
S

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
 
P

Patrice

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top