I have some exe files that I’ve uploaded into my database as I don’t want them to be publicly accessible. I tried using a link button and a generic handler to serve the file using the following code:
Context.Response.Clear()
Context.Response.ContentType = "application/exe"
Context.Response.AppendHeader("Content-Disposition", "filename=program.exe")
Context.Response.BinaryWrite(binaryfile)
The problem: Google Chrome does not treat the download as any other exe, instead after downloading it reports “program.exe is not commonly downloaded and could be dangerous.” with a “discard” button and the option to “keep” the download is hidden under a context menu.
Is there any other/better way to serve exe files stored in the database?
I don’t often see
application/exein the wild. It’s more common to useapplication/octet-streamfor executable files.If you’re using .NET, then I’m going to assume for a moment that you’re using IIS. (Correct me if this is not the case.) If so, then this (old, but still useful) list of MIME types and file extensions may be helpful.
Naturally, you won’t be able to get around any browser-side restrictions from the server side in any real sense. You can modify the headers you send to the client, but in the end it’s up to the client what to do with the response.