Z
zee
All,
I have used this code for the past 3-4 years and never had any problem
with any version of .NET or Adobe Reader. It is supposed to open a PDF
in a new browser window.
I copied this code to a new page in the same web application and it
does not work. To describe how it does not work; the resulting ASPX is
just blank. No PDF. No Adobe toolbar. Nothing.
I've tried all sorts of variations on the code but no luck. I tried
adding a Response.End to the end of the code, but this threw an error.
???
It still works fine in the original page though. Very wierd.
Can anyone provide some insight here?
Note: This code run perfectly for Adoe Reader 8 but not for earlier
versions....
I want this code to run on all versions
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ASPX code: Just the @Page directive, nothing else
FileStream MyFileStream = new
FileStream(Session["FileToLoad"].ToString(), FileMode.Open,
FileAccess.Read);
Byte[] Buffer = new byte[MyFileStream.Length];
MyFileStream.Read(Buffer, 0,
Convert.ToInt32(MyFileStream.Length));
MyFileStream.Close();
Response.BufferOutput=true;
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Length",
Buffer.Length.ToString());
Response.AddHeader("content-disposition",
"inline;filename=YourReport.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(Buffer);
Response.Flush();
Response.Clear();
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
another piece of code but not a solution
string type =
Session["FileToLoad"].ToString().Substring(Session["FileToLoad"].ToString()..IndexOf(".")
+ 1);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition",
"inline;filename=File." + type);
Response.ContentType = "application/" + type;
Response.WriteFile(Session["FileToLoad"].ToString());
Response.Flush();
Response.Close();
I have used this code for the past 3-4 years and never had any problem
with any version of .NET or Adobe Reader. It is supposed to open a PDF
in a new browser window.
I copied this code to a new page in the same web application and it
does not work. To describe how it does not work; the resulting ASPX is
just blank. No PDF. No Adobe toolbar. Nothing.
I've tried all sorts of variations on the code but no luck. I tried
adding a Response.End to the end of the code, but this threw an error.
???
It still works fine in the original page though. Very wierd.
Can anyone provide some insight here?
Note: This code run perfectly for Adoe Reader 8 but not for earlier
versions....
I want this code to run on all versions
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ASPX code: Just the @Page directive, nothing else
FileStream MyFileStream = new
FileStream(Session["FileToLoad"].ToString(), FileMode.Open,
FileAccess.Read);
Byte[] Buffer = new byte[MyFileStream.Length];
MyFileStream.Read(Buffer, 0,
Convert.ToInt32(MyFileStream.Length));
MyFileStream.Close();
Response.BufferOutput=true;
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Length",
Buffer.Length.ToString());
Response.AddHeader("content-disposition",
"inline;filename=YourReport.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(Buffer);
Response.Flush();
Response.Clear();
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
another piece of code but not a solution
string type =
Session["FileToLoad"].ToString().Substring(Session["FileToLoad"].ToString()..IndexOf(".")
+ 1);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition",
"inline;filename=File." + type);
Response.ContentType = "application/" + type;
Response.WriteFile(Session["FileToLoad"].ToString());
Response.Flush();
Response.Close();