I have a piece of code that generates a csv file dynamically. The user clicks a button, I prepare the string and then I do so something like:
MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(sb.ToString()));
Response.Clear();
Response.ContentType = "Application/csv";
Response.AppendHeader("content-disposition", String.Format("attachment; filename={0}.csv", fileName.ToString()));
Response.BinaryWrite(stream.ToArray());
Response.End();
The user is then prompted to download or save the newly generated file. The problem is that after this I have to refresh some data in the page. After the Response.End this is not possible anymore.
Any ideas on how to overcome the problem?
.DestinationPageUrl="~/User/Default.aspx";
– Rafee