Internet explorer used to prompt a user to download an excel file after doing a Response.Write
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=\"sheet.xls\"");
Response.RedirectLocation = "export.xls";
Response.Charset = "";
EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
dataGridResult.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
This works when I POST back to a page with a button click event.
I am using a page as a service and doing a $.get()
, but the results are sent back as HTML. I am not prompted to open the excel file. How can send the prompt out to the user?
$.get('ExcelService.aspx',
{ batches: input },
function (data) {
alert(data);//I see HTML
});