473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASPX page to stream a PDF

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();

Jan 4 '07 #1
0 976

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3132
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something...
1
1828
by: Bhupesh Saini | last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page....
1
1420
by: Daniel | last post by:
streaming random filetypes from .aspx how to stream a file from inside a .aspx? e.g. so one could go href="./foo.aspx?file=bar.mp3" or href="./foo.aspx?foo.dat" etc. preferabley i would like...
6
3008
by: Tony K | last post by:
I have the most peculiar problem with an ASP.NET page which we use for downloading a file. When the user clicks on a link, the link points to an ASPX page which downloads the file selected. ...
5
10054
by: Earl Teigrob | last post by:
I am creating an application where I would like to give web designers the ablity to create a static html page and dyanamically load it into my application(exactly like loading a user control into a...
1
8954
by: Patrick F | last post by:
I cant figure out what mimetype .aspx pages are, i have been searching thru msdn and the only thing that i found was a way to list all mimetypes installed on the computes, output something like...
2
1509
by: Jim712 | last post by:
I am trying to embed an aspx page within another aspx page. Is it possible to persist the data to the embedded page?
5
2057
by: Simon Rigby | last post by:
Hi folks, Apologies if this is not directly relevant but I was struggling to find a group with the appropriate context. So as my problem is in an aspx web site I thought I'd try here first....
12
4747
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page...
1
3668
by: ERobishaw | last post by:
Using Winform app writing a HTTP Post using the following... on the server side, I get no form fields. Request.Form.AllKeys.Length = 0. If I put the field/value paris in the URL I can use...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.