I have two byte[] arrays, objResult1 and objResult2, which contain data from
two separate calls to Render().
I would like to somehow write the results for both reports to the Reponse
object.
This is the code I have:
HttpResponse objResponse = System.Web.HttpContext.Current.Response;
objResponse.ClearContent();
objResponse.ClearHeaders();
string fileName = Path.GetFileName(this.ReportPath) +
".pdf";
objResponse.ContentType = this.strMimeType;
objResponse.AddHeader ("content-disposition",
"attachment; filename=\"" + fileName + "\"");
objResponse.BinaryWrite(objResult1);
objResponse.BinaryWrite(objResult2);
objResponse.Flush();
objResponse.Close();
Unfortunately when I do this, the contents of objResult1 are not visible
i.e. the 2nd call to BinaryWrite overwrites the first one.
How can i simply append the second byte array?
Any help will be much appreciated...
Thanks.You can combine two arrays by using static Array.Copy call. Just create a
new array sized as a sum of two and copy your array one by
one to the new one. Be aware, if the mime types of the webresponses are
different you'll get a garbled output.
Also, BinaryWrite should not override the previous write.
The reason of missing the first write is writing file header information
twice, thus only one will be visible, if you lucky enough, otherwise you can
get some garbage
I'd use frames or iframes, if needed to display output from two different
pages on a single one.
"Aparna" <Aparna@.discussions.microsoft.com> wrote in message
news:53A315A1-FFD7-48BF-99D0-84D63BD062C3@.microsoft.com...
>I have two byte[] arrays, objResult1 and objResult2, which contain data
>from
> two separate calls to Render().
> I would like to somehow write the results for both reports to the Reponse
> object.
> This is the code I have:
> HttpResponse objResponse => System.Web.HttpContext.Current.Response;
> objResponse.ClearContent();
> objResponse.ClearHeaders();
> string fileName = Path.GetFileName(this.ReportPath) +
> ".pdf";
> objResponse.ContentType = this.strMimeType;
> objResponse.AddHeader ("content-disposition",
> "attachment; filename=\"" + fileName + "\"");
> objResponse.BinaryWrite(objResult1);
> objResponse.BinaryWrite(objResult2);
> objResponse.Flush();
> objResponse.Close();
> Unfortunately when I do this, the contents of objResult1 are not visible
> i.e. the 2nd call to BinaryWrite overwrites the first one.
> How can i simply append the second byte array?
> Any help will be much appreciated...
> Thanks.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment