I have googled this, searched this, looked through SO and other sites (I've been trying to read on this issue for hours now), but I still can't seem to find a satisfactory solution to what seems to be a simple, common programming issue.
Let me set the scene:
Every solution I've tried so far has some basic problems wrong with it:
I can't figure it out! I'm really a desktop developer, and this was EASY in Windows! Why is it so hard with the web?
Am I stupid and this is really an easy exercise, or is this basic task really that hard?
Please help point me in the right direction!
Thanks!!!
Have you tried adding a http header with content-disposition-inline? Also you may want to write the result directly to the output response instead of saving it. This would ensure the files actual path is not displayed as your writing it to the response directly.
Eg
Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition","inline");
Response.BinaryWrite(myfilestream.ToArray());
Where myfilestream is a memory stream or if you already have a byte array from your blob you can write it directly to the response without the toarray
This link might be useful to you,
http://nilangshah.wordpress.com/2007/05/28/successfully-stream-a-pdf-to-browser-through-https/
You can have pdf opened in a new tab by speccifying target="_blank" for the link. ByteArray mentioned in the blog is your BLOB from the DB. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With