473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem with pdfs

My aspx page code reads some custom values from the HTTP headers and then
writes a given pdf to the output stream based upon the header values.
Unforunately, my code causes IE to pop up an Open / Save dialog instead of
invoking the Adobe plugin and displaying the pdf inside of I.E. Here is my
code (file points to a valid pdf and mimetype is set to 'application/pdf')

private void RenderFile(FileInfo file, string mimeType){

this.Context.Response.ContentType = mimeType;

Debug.WriteLine(this.Context.Response.ContentType) ;

this.Context.Response.AddHeader("Content-Length",
file.Length.ToString());

byte[] buffer = new byte[1024];
int bytesRead = -1;

FileStream fs = new FileStream(file.FullName, FileMode.Open,
FileAccess.Read);
Debug.WriteLine(fs.Length);

Stream output = this.Context.Response.OutputStream;

int i = 0;
while ( (bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0 ){

output.Write(buffer, 0, bytesRead);
}

output.Close();
}

Watched the HTTP traffic through a tunnel and noticed that ASP.NET is
tacking on a content-type of utf-8 on the response (even though my code set
it to application/pdf).

HTTP request
GET /webtier/PcFileRetriever.aspx?queryStringParams omitted for brevity
HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
*/*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.1.4322)
Host: localhost:81
Connection: Keep-Alive
Cookie: ASP.NET_SessionId=dqnbdy45x0plax344a1drb55

HTTP response
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 16 Jul 2003 19:41:41 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: application/pdf; charset=utf-8
Content-Length: 12850530

Anyone know how to properly stream the pdf file so the IE Adobe browser
plugin displays it instead of prompting the user to save? thanks

scott
Nov 17 '05 #1
0 1481

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

Similar topics

3
by: Mark | last post by:
Hello, I am new to PERL and I want to do a simple function (in LINUX): find all files that have the extension pseudo.pdf and put the file names in a file; parse the file and change all file...
0
by: billby | last post by:
Hi all, I am trying to solve a problem on a production server, that unfortunately is not repeatable on our development server. It is for a bank, and the site is being hosted by a different...
8
by: Martin Emanuelsson | last post by:
Hello, I have a problem with a small asp-solution that searches for PDF-documents with indexing service. For some files in the search result I get gibberish returned, such as...
4
by: Ragnar Heil | last post by:
Hi, I want to produce .fo-documents and now I am searching for a fo-processor which can transform them into secure pdfs. I don´t want to touch every pdf manually to set security settings like...
14
by: BlueDolphin | last post by:
Hello all. I'm looking for some opinions on using snapshot files or ..pdf for some reports. We are in the initial stages of creating some reports in access that will be pulled online through Cold...
2
by: Pawan | last post by:
Hi Guys, I have this current assignment where I have to develop online forms for local municipal authorities. I have to use adobe acrobat to create online forms from PDFs (which I have never done...
3
by: Null | last post by:
Hello -- I am looking for a way to dynamically generate PDF documents - combining Crystal Reports and data driven "fields". For example, I have a template that's essentially a summary document...
3
by: Mike Kingscott | last post by:
Hi there, I'm writing an app in which a punter buys some PDFs online. After purchasing said PDFs, they will be given a token (bless them Guids) to go to a download .ASPX page from which they can...
0
by: praveenkhade | last post by:
I am working on asp.net ,C#. The pdf files in the grid are displaying properly. The main prob is that in these pdfs one pdf is the main like an index ,if i open this pdf i can link to rest of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.