473,569 Members | 2,836 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(Sess ion["FileToLoad "].ToString(), FileMode.Open,
FileAccess.Read );

Byte[] Buffer = new byte[MyFileStream.Le ngth];

MyFileStream.Re ad(Buffer, 0,
Convert.ToInt32 (MyFileStream.L ength));
MyFileStream.Cl ose();

Response.Buffer Output=true;
Response.ClearC ontent();
Response.ClearH eaders();
Response.AddHea der("Content-Length",
Buffer.Length.T oString());
Response.AddHea der("content-disposition",
"inline;filenam e=YourReport.pd f");
Response.Conten tType = "applicatio n/pdf";
Response.Binary Write(Buffer);

Response.Flush( );
Response.Clear( );
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''
another piece of code but not a solution
string type =
Session["FileToLoad "].ToString().Sub string(Session["FileToLoad "].ToString()..In dexOf(".")
+ 1);
Response.ClearC ontent();
Response.ClearH eaders();
Response.AddHea der("Content-Disposition",
"inline;filenam e=File." + type);
Response.Conten tType = "applicatio n/" + type;
Response.WriteF ile(Session["FileToLoad "].ToString());

Response.Flush( );
Response.Close( );

Jan 4 '07 #1
0 979

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

Similar topics

6
3138
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 like http://myserver/mypage.aspx. From there it gets blurry, because I just can't figure out how to do the rest. Does anybody have a sample page...
1
1840
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. What do I need to do to have the cookies sent along with the request Below is the code snippet from the function I an using I am using to achieve...
1
1426
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 all file types to open with "save as" when href clicked
6
3011
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. The code works fine except after the user saves the file, the links on the left side of the frameset do not work. IE locks up.
5
10063
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 page). Is there an easy way to do this or do I need to stream the html into my application and parse unwanted header/footer info before rendering...
1
8959
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 this: Microsoft (R) Windows Script Host Version 5.1 for Windows Copyright (C) Microsoft Corporation 1996-1999. All rights reserved. Total MIME Map...
2
1514
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
2062
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. Please feel free to suggest a more relevent group. I have some code that I am using to build a stream (test text at this stage, although eventually...
12
4754
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 on the client's computer? He/she could do this using the browser (file/save), but I need to have it done by pressing the pushbutton. In my...
1
3679
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 Request to retrieve the values, but POST doesn't work. There is NO Proxy... the only thing I can think is that ASP.NET is somehow filtering out the...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.