I implemented a generic handler in my application which works great for images, but when I manually type the handler URL in the browser with the image\'s querystring it prom
If you store the ContentType
as part of the files metadata, when you pull it back down your could use it.
theFile = GetFile(id)
context.Response.ContentType = theFile.Type;
The only way is to specify correct ContentType so the browser know what to do with receiving file, depending on installed plugins (for example, view pdf files in browser frame) and system assosiations (for example, offer to open document in MS Office instead of simple download)
You can try to specify Content Type depending on file extension, i.e.:
if(Path.GetExtension(path) == ".jpg")
context.Response.ContentType = "image/jpeg";
else
context.Response.ContentType = "application/octet-stream";
The content-disposition header is the one that causes your browser to show the download dialog. Remove that line and it will show in the browser.