Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem with pdfs

Reply
Thread Tools

problem with pdfs

 
 
Scott McFadden
Guest
Posts: n/a
 
      07-16-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in displaying PDFs on Google Chrome HinaAsp.Net ASP .Net 0 05-12-2011 09:55 AM
problem with staticfilehandler + PDFs with fast webview -Lineariza Mainframe05 ASP .Net 0 09-18-2009 08:46 PM
Re: Where to download latest TestKing PDFs? C_TESTORE Microsoft Certification 0 12-13-2004 03:00 AM
Problem when searching for PDFs with Indexing Service in ASP-solution. Martin Emanuelsson ASP General 7 10-18-2004 03:50 PM
IP PBX Tutorials, whitepapers, pdfs learning site -- free access... ShaperShifter Cisco 0 06-07-2004 05:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57