In my ASP.NET Web Forms application, I have to download a string as a file right after i'm doing an action on the web page. The flow is as follows:
- Do initial action (button click)
- It opens up a popup window where the username and password are required.
- Fill in the username and password
- Do second action (button click inside popup)
Now, after the second action is done, I want my page to reload and start downloading my string as a file.
If I write my string in the response like below, the file gets downloaded, but the pop-up window does not close.
Response.Write(mystring);
I tried these ways:
Context.Response.Clear(); Response.AddHeader("Content-Disposition", "inline; filename=Warrants.warrant"); Response.ContentType = "application/lsw_print"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(mystring); Response.Flush(); Response.End();
2.
Context.Response.Clear();
Response.AddHeader("Content-Disposition", "inline; filename=Warrants.warrant");
Response.ContentType = "application/lsw_print";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(mystring);
Response.Flush();
ApplicationInstance.CompleteRequest();
Context.Response.Clear(); Response.AddHeader("Content-Disposition", "inline; filename=Warrants.warrant"); Response.ContentType = "application/lsw_print"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(mystring);
All these versions download my file, but ends the requests and my pop-up doesn't get closed.
Also, the popup I use is a control having an iframe in it.
Thanks!