I'm streaming a pdf from an .ashx file to the browser using the following code:
context.Response.Clear();
context.Response.Charset = "";
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Disposition", "inline;filename=test.pdf");
context.Response.AddHeader("content-length", stream.Length.ToString());
stream.WriteTo(context.Response.OutputStream);
context.Response.Flush();
context.Response.End();
where context comes from:
public void ProcessRequest(HttpContext context)
All works well when using Chrome or Firefox and it displays on the browser. But when I use IE 11 I get a blank screen. If I go to Adobe Reader->Edit->Preference->Internet and uncheck "Display PDF in browser" then from IE it opens Adobe Reader and shows the PDF properly. But as soon as I unchecked "Display PDF in browser" then it just shows the blank screen:
If I go to IE "Manage Add-ons" it shows that Adobe is enabled:
I've seen other post but nothing seems to work. I'm thinking its an IE thing since Chrome and Firefox works and with IE displays if I don't have it load on the browser.
Any ideas on what could be causing this?
Update: Fiddler Data:
Here is what I got from Fiddler. Nothing stands out between Chrome and IE except that IE doesnt work:
Chrome: Request:
GET /FileDownloadHandler.ashx?session=agenda_item_number_download&id=6079&downloadtoken=635685165181990000 HTTP/1.1 Host: localhost Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36 Referer: http://localhost/FileDownload.aspx?session=agenda_item_number_download&id=6079 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8,es;q=0.6,ru;q=0.4 Cookie: ASP.NET_SessionId=n3r0p3lgrnsherwl0iid3ser
Response:
HTTP/1.1 200 OK Cache-Control: private Content-Length: 150173 Content-Type: application/pdf Server: Microsoft-IIS/8.0 Content-Disposition: inline;filename=test.pdf X-AspNet-Version: 4.0.30319 Set-Cookie: DownloadSessionToken=635685165181990000; path=/ X-SourceFiles: =?UTF-8?B?QzpcUHJvamVjdHNcTUNXZWJBcHBsaWNhdGlvbnNcU291cmNlXE1vaGF2ZUNvdW50eVxGaWxlRG93bmxvYWRIYW5kbGVyLmFzaHg=?= X-Powered-By: ASP.NET Date: Fri, 29 May 2015 17:15:19 GMT
IE:
Request:
GET /FileDownloadHandler.ashx?session=agenda_item_number_download&id=6079&downloadtoken=635685164869660000 HTTP/1.1 Accept: text/html, application/xhtml+xml, / Referer: http://localhost/FileDownload.aspx?session=agenda_item_number_download&id=6079 Accept-Language: en-US User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko Accept-Encoding: gzip, deflate Connection: Keep-Alive DNT: 1 Host: localhost Pragma: no-cache Cookie: ASP.NET_SessionId=1ekxziruzsstknjubyugl3ur
Response:
HTTP/1.1 200 OK Cache-Control: private Content-Length: 150173 Content-Type: application/pdf Server: Microsoft-IIS/8.0 Content-Disposition: inline;filename=test.pdf X-AspNet-Version: 4.0.30319 Set-Cookie: DownloadSessionToken=635685164869660000; path=/ X-SourceFiles: =?UTF-8?B?QzpcUHJvamVjdHNcTUNXZWJBcHBsaWNhdGlvbnNcU291cmNlXE1vaGF2ZUNvdW50eVxGaWxlRG93bmxvYWRIYW5kbGVyLmFzaHg=?= X-Powered-By: ASP.NET Date: Fri, 29 May 2015 17:14:47 GMT
Fix Update
Ok it seems like its an Adobe Reader problem. I found the problem because eventually my stream would produce a 103:103 error. After doing some searches I found where it says to do the following:
Launch Adobe Reader In "Adobe Preferences" open menu "General" Untick (uncheck) the setting "Enable Protected Mode at startup" If that doesn't do anything uninstall the software, run adobe cleaner tool and then reinstall the software.
And now its working properly. Ive included the CC Tool in case anyone wants to use it.