Streaming PDF using .ashx

P

Paul

This is not a question,

More a heads up in case anyone else gets this problem.

We have an HTTP Handler that spits out PDF files.
During development we chose to use the .ashx file to provide the
mapping ( saving us registering on each machine etc )

However, this produced unexpected problems with IE6 refusing to render
the PDF file.

The important point here is that as a standalone Handler it works as
intended.
The code in a standard page even works.

But put it in an ashx file and for some reason the browser does not
receive the header info.

It was only IE6 that caused this problem.

Hope this save people time.

Our code for those interested

......

if (File.Exists(_sBillPdfFilePath) && _bError ==
false)
{
//Response.Write("<pre>");
//Response.Write(_sFopResult);
//Response.Write("</pre>");

try
{
string sFile = "filename=" + "billData" +
".pdf";
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition",
sFile);

Response.TransmitFile(_sBillPdfFilePath);

}
catch (Exception e)
{
Trace.Write("Could not write PDF to Response
object.");
Trace.Write(e.Message);
Trace.Write(e.Source);
}
}
else
{
Response.Write("<pre>");
Response.Write("The printed bill could not be
generated - please try again later.");
if (util.getApplicationContext().devMode)
{
Response.Write(_sFopResult);
}
Response.Write("</pre>");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top