I have a few linkbuttons that each open the save dialog to let users save file to the local machine. But after any link is clicked the page is dead afterwards (nothing works) and page has to be refreshed.
So do I have to force refresh after download is complete or does it have to do something with postback?
{
StringCollection strValuesToSearch = new StringCollection();
strValuesToSearch.Add("findword");
string stringToReplace;
stringToReplace = TextBox1.Text;
using (StreamReader reader = new StreamReader(Server.MapPath("~/test.txt")))
{
string result = reader.ReadToEnd();
foreach (string s in strValuesToSearch)
{
if (result.Contains(s))
result = result.Replace(s, stringToReplace);
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=super.txt");
Response.ContentType = "text/plain";
UTF8Encoding encoding = new UTF8Encoding();
Response.BinaryWrite(encoding.GetBytes(result));
Response.Flush();
Response.End();
In the absence of client-side code, this is just a wild guess at what is causing the issue:
getorpostajax call to the server, sending some datacontent-dispositionheader followed by the file data