My task is very simple, on Button Click I want to show the generated PDF on the browser but at the same time download it on the client machine.
I have made 2 functions, One for downloading & other for showing it on browser. When I run them separately they work like a charm but when I call them together on button click only the that is called first works other one just doesn't do anything.
Below is the code to download the file.
_page.Response.Clear();
_page.Response.AddHeader("Content-Disposition", "attachment; filename=payments.xls");
//Download the file and prompt the user to save
_page.Response.BinaryWrite(data);
_page.Response.End();
Below is the code to show on browser
_page.Response.Clear();
_page.Response.ContentType = "application/pdf";
_page.Response.OutputStream.Write(_datastrem.GetBuffer(), 0, _datastrem.GetBuffer().Length);
_page.Response.Flush();
**I also should mention that I want to do all that on POSTBACK.