Busy with some legacy code to write to csv / xls:
string filename = "ErrorControlExport";
string attachment = "attachment; filename=" + filename + "_" + DateTime.UtcNow.ToFileTime() + "." + extension;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = contentType;
HttpContext.Current.Response.AddHeader("Pragma", "public");
HttpContext.Current.Response.Filter = null;
byte[] bom = new byte[] { 0xef, 0xbb, 0xbf };
HttpContext.Current.Response.BinaryWrite(bom);
However, when the code reaches:
HttpContext.Current.Response.Filter = null;
he throws out HttpExceptionof
The response filter is invalid.
So my questions are:
1) How to set the filter to empty or the default filter?
2) Is it even necessary?
Thank you in advance for your help.
source
share