Double prompt while Downloading the file in ASP.NET

A

arc

I am using this simple code snippet in downloading file but it gives me
double prompt while opening the file. Save is fine.
What could be the problem?

private void Page_Load(object sender, System.EventArgs e)

{

string sFilename = Request.QueryString["file"];

string sFile =
System.Configuration.ConfigurationSettings.AppSettings["FilePath"] +
sFilename;

Response.Clear();

Response.ContentType = "application/octet-stream";

Response.AddHeader("content-disposition", "attachment; filename=" +
sFilename.Substring(sFilename.IndexOf("_")+1));

Response.Flush();

Response.WriteFile(sFile);

}

Thanks
Arc
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top