how to force download dialog for a text file on the server?
when i used the blow code so the dialog window was for aspx file … (why?)
string FileBankPhysicalFolder = Server.MapPath("~/FileBanks/");
string Name = "FileBank_" + "Melli_" + Session["Co_ID"].ToString() + "_" + RadcbDateOfPardakht.SelectedValue.Replace('/',',') + ".txt";
string FileBankPath = FileBankPhysicalFolder + Name;
string Content = Header + Body;
System.IO.File.WriteAllText(FileBankPath, Content);
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment;" + Name);
Response.WriteFile(FileBankPath);
Response.End();
how can i fix this problem?
You should send force-download headers along with the file. I don’t know how you would do that in ASP but basically you have to read the file with some ASP built-in function then output it to the browser attaching
Judging by your code:
Cheers!