I have a database that stores PDF documents as a byte stream in a varbinary(max) column, The original document name is stored in a varchar column with the document extension and the primary key is a guid. (This schema is fixed, documents must reside in the database)
There are no problems retrieving the document as a stream and either writing to a temporary file or streaming directly to a web browser.
My question is how could the document also be exposed via a Url using it’s original file name?
An good example of what I am trying to do is SharePoint, Under the covers SharePoint stores the files inside the SQL database and exposes the document as a Url (With original file extension) that can be directly opened with a browser.
eg: http://WebServer/Documents/MyDocument.pdf
(The platform is SQL 2008, IIS 7.5, .NET 4, C#)
If your site uses ASP.Net MVC you can just add controller for /Documents download file by name:
And controller class: