Forces to prompt download box IE

Posted by Bruno Costa on Stack Overflow See other posts from Stack Overflow or by Bruno Costa
Published on 2011-02-25T14:21:45Z Indexed on 2011/02/28 23:24 UTC
Read the original article Hit count: 263

Hello,

I'm having a problem with some reports in the application I'm doing manutention

I've a button that does a postback to the server and do some information and then get back to the cliente and open a popup to download the report.

    private void grid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
 ...
 ClientScript.RegisterClientScriptBlock(this.GetType(), "xxx", "<script>javascript:window.location('xx.aspx?m=x','xxx','width=750,height=350,directories=no,location=no,menubar=no,scrollbars,status=no,toolbar=no,resizable=yes,left=50,top=50');</script>");
}

Then in xxx.aspx I've the code:

 Response.ClearContent();
 Response.ClearHeaders();
 Response.TransmitFile(tempFileName);
 Response.Flush();
 Response.Close();

 File.Delete(tempFileName);

 Response.End();

This works fine if IE option Automatic prompting for file downloads is enabled. But by default this is disabled and I need to force the download box to be prompting.

Can I do anything without change a lot of code?

Thanks.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about ASP.NET