Monday, November 03, 2003


Source: WebLogs @ ASP.NET

If you've ever created an Http Handler to send down files dynamically say, for a document manager or maybe just an ASPX that returns a dynamic image, you've probably noticed that when the page or handler opens up something that doesn't have recognizable file extension that it doesn't know how to open it and you have to tell it how to open it.  A big pain for the end user for sure.

A collegue of mine sent me some code he found today or streaming a dynamic PDF generated from CrystalReports to the client, I noticed a piece of code.

Response.AddHeader("Content-Disposition", "inline; filename=Report.pdf")

I added it into our document manager and what do you know, it now actually fakes the filename when opening up that dynamic page or Http Handler.  So all you have to do is add that line before you send the bytes of the file down to the client and it will always open up “appropriately” on the client.

[WebLogs @ ASP.NET]
6:27:17 PM    trackback []     Articulate []