开发者

Firefox sporadically displays file stream instead of a document

When user requests to download a document, I'm writing out a PDF file to HttpResponse using HttpResponse.OutputStream.Write method. It works in every browser except Firefox(3.5.8). In Firefox it sometimes displays the file and sometimes it displays the actual byte stream. When it displays a byte stream, http response is never finished. I see 'transferring data' status and the byte stream ends 开发者_如何学Gowith EOF. After some time, I get 'connection was reset' window.

alt text http://img31.imageshack.us/img31/7907/displaybytes.png alt text http://img193.imageshack.us/img193/7246/displayendofstream.png alt text http://img211.imageshack.us/img211/1774/timeout.png

Here is response header:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 103185
Content-Type: application/pdf
Expires: -1
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
Content-Description: stuff.pdf
Content-Disposition: inline;filename="stuff.pdf"
X-Powered-By: ASP.NET
Date: Mon, 22 Feb 2010 16:15:38 GMT


It might have also to do with the action assigned to the mime type of the document. For instance in FF this actions can be set.

But of course you also need to make sure the server is streaming the correct mime type.


I think the issue is most likely in Firefox or with the Acrobat plugin.

Whenever something works sometimes but not others, you have to pay real close attention to the differences. The issue is always in the differences.

In your case, you may never know why, because the differences may be in the browser or the plugin. Your header looks like it is supposed to look. It works in all other browsers. Based on your header, this is the way it is supposed to work in this browser, too.

I would pose this to Mozilla and see what they have to say.

As a potential workaround, You could try changing your Content-Disposition to 'attachment' when your user's browser is FF. This would cause the "Open or Save" dialog box to appear. Then your user can still click "open" to view it in the page.

Content-Disposition: attachment; filename=stuff.pdf


We have had this problem when the PDF file being rendered inline is under source control and it is readonly. We are using VSS for our source control and when we deployed the PDF it rendered exactly like what you have in the screen shot. We then put fresh copy of PDF then it worked just fine. Maybe check if the PDF is readonly and if so try taking out the readonly attribute and try again.

Hope this helps.

Thanks,

Raja


If you right click and save as does it save as a proper PDF you can look at? I suspect you are writing out the PDF incorrectly or your header is wrong.


Looks like it wasn't finishing up request. Solution is to put Response.End() at the end.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜