Internet explorer is used to request the user to download the excel file after completing 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 send a POST to a page with a button click event.
I use the page as a service and do $.get() , but the results are sent back as HTML. I am not prompted to open the excel file. How to send a request to a user?
$.get('ExcelService.aspx', { batches: input }, function (data) { alert(data);
source share