Tuesday, June 10, 2008

Open PDF

If you want to open a pdf file in browser or any attachment, you would have used the

Response.AddHeader("Content-Disposition", "attachment; filename=" + TheFileName);

Then you either do a BinaryWrite or a WriteFile. A WriteFile opens in the browser as inline attachment. A binary write opens the attachment with a dialog box to open,save or cancel

When the user opens the attachment, you can sometimes see the IE behaves very strangely and does not open the attachment. However,if you save the attachment the attachment is saved correctly and can be viewed. This can be annoying.

We tried to find a solution to this problem, but it looks like it is a IE 6.0 problem. (Oh Good lord, That IE Dev team!! )

This problem is not new and almost every big company like AmericanExpress,BankofAmerica have this issue. Try downloading a pdf from their site..

One thing that can be done to avoid this is to altogether avoid the open option. this can be done by using this meta tag:
start tag meta name="DownloadOptions" content="noopen" / end tag

Or else, Ask your users to be smart and use browsers like FireFox! :)

I hope Microsoft IE dev team reads my blog and takes care of this issue some day.. Its never the end of the world.

No comments: