I'm trying to create an Excel file from a byte[] array after reading the data from a DataTable using a DataTableReader, all this in a ashx file. But it's just not working. Here I post some code:
DataTableReader RS = dt.CreateDataReader();
byte[] byteArray = GetData(RS);
context.Response.ContentType = "application/ms-excel";
context.Response.Clear();
// context.Response.Charset = "";
try
{
context.Response.BinaryWrite(byteArray);
context.Response.OutputStream.Write(byteArray, 0, byteArray.Length);
context.Response.BufferOutput = true;
context.Response.Flush();
}
catch (Exception ex)
{
SendMail(ex.Message.ToString());
}
It throws the following exception:
context.Response.SubStatusCode threw an exception of type System.PlatformNotSupportedException. {"This operation requires IIS integrated pipeline mode."} ashx
I know that if I use the headers need to have IIS7 or Framework 3+.
Any help would be appreciated!!