I have documents (images, Word documents, PDF’s, etc) stored in an SQL Server database table. On my form, I display the names of these documents and need for the user to be able to click a document title and have the contents retrieved from the database and then opened in the default viewer; Word for example for a Word document.
I’m not sure about the best way to approach this. I tried using an $.ajax call to a web service that queries the database and then write the bytes out to the current context but this doesn’t seem to work.
Any tips would be greatly appreciated.
You can use this approach:
Change the Response.ContentType to the correct type of content being streamed, which you can do by examining the extension of the file.