> Try adding before Response.BinaryWrite(...) the line
Ya better write bit by bit
string _filePath = "..."
Response.Clear();
Response.AddHeader("Content-Disposition", "inline");
Response.ContentType = "application/pdf";
Response.Buffer = false;
FileStream _fileStream = null;
byte[] _buffer = new byte[1024];
long _byteCount;
try
{
_fileStream = File.OpenRead(_filePath);
while ((_byteCount =
_fileStream.Read(_buffer, 0, _buffer.Length)) > 0)
{
if(Response.IsClientConnected)
{
Response.OutputStream.Write(
_buffer, 0, _buffer.Length);
Response.Flush();
}
else
{
return;
}
}
}
catch(Exception _ex)
{
throw _ex;
}
finally
{
_fileStream.Close();
}
--Daniel
http://staff.newtelligence.com/danielf/
-----Original Message-----
From: Paul Henderson [mailto:pa***********@pittville.demon.co.uk]
Posted At: Monday, January 23, 2006 12:36 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: File Open and Save dialog poping up while opening PDF
Subject: Re: File Open and Save dialog poping up while opening PDF
I am trying to display a PDF file (which I am being passed from a web
service as a binary stream) in a browser, but I am being prompted to
save the file instead. I don't want the user to be prompted; I just
want the PDF to be displayed.
Try adding before Response.BinaryWrite(...) the line
Response.AddHeader("Content-Disposition", "inline");
to tell the browser to show the document inline. Note however that the
problem *could* actually be on the client side, as Adobe Reader
sometimes refuses to show a PDF inline, even when the
content-disposition is set to 'inline'.