Skip to content Skip to sidebar Skip to footer

Aspx Page To Download Any Type Of File From A Specific Directory On Web Server

I had a quick requirement from my client that he want to store some files in a Folder in web server (we have a temp folder which has rights to allow Everybody). He want to place th

Solution 1:

Check this post for answer, to get MIME type which should be set for your content Type

Using .NET, how can you find the mime type of a file based on the file signature not the extension

Or you can just put, which should work fine for downloading binary file. Response.ContentType = "application/octet-stream";

        Page.Response.ContentType = "application/octet-stream"
        Page.Response.AddHeader("Content-Disposition", "attachment; filename=""" & strFilename & """")
        Page.Response.OutputStream.Write(objAttachment.Data, 0, objAttachment.Data.Length)

Post a Comment for "Aspx Page To Download Any Type Of File From A Specific Directory On Web Server"