Downloading files - prompt shown twice

M

Marina

Hi, I have the following code to prompt the user for a download:
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment;filename=test.pdf")
Response.WriteFile("C:\test.pdf")
Response.End()

This works well, as far as prompting the user for download.

However, if I chose "Open", I then get the same prompt again. If I chose 'Open' the second time,then the file actually gets downloaded and opened.

This double prompt issue does not happen if i chose Save. This works as expected.

Anyone know what's going on?
 
S

S. Justin Gengo

Is this code in the same page as the link to download the file?

When the download link/button is clicked try opening a new window with the code below in it.

--
S. Justin Gengo, MCP
Web Developer / Programmer

Free Code Library At:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


Hi, I have the following code to prompt the user for a download:
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment;filename=test.pdf")
Response.WriteFile("C:\test.pdf")
Response.End()

This works well, as far as prompting the user for download.

However, if I chose "Open", I then get the same prompt again. If I chose 'Open' the second time,then the file actually gets downloaded and opened.

This double prompt issue does not happen if i chose Save. This works as expected.

Anyone know what's going on?
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top