Unable to download the .7z extension file through application

9.4k views Asked by At

Am trying to download the .7z file using our website application.But it shows the below error.

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map can anyone suggest me how can I resolve this issue?

Thanks in advance. Regards, Nithya G

4

There are 4 answers

2
Lance On BEST ANSWER

You need to set the MIME type on the server:

application/x-7z-compressed

How to set MIME Types on IIS: http://www.iis.net/configreference/system.webserver/staticcontent/mimemap

0
hakan On

You need to add relevant mime types to IIS on your server.

0
SteveFerg On

Here is an example using a button:

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

code behind:

protected void Button1_Click(object sender, EventArgs e)
{
    Response.ContentType = "APPLICATION/OCTET-STREAM";
    String Header = "Attachment; Filename=x.7z";
    Response.AppendHeader("Content-Disposition", Header);
    System.IO.FileInfo Dfile = new System.IO.FileInfo(Server.MapPath("~/x.7z"));
    Response.WriteFile(Dfile.FullName);
    //Don't forget to add the following line
    Response.End();

}

In IIS you may want to set the MIME type as so: enter image description here

0
Zeeshan On

along with setting up MIME type, you also need to add a new Managed Handler, with Request Path set to *.7z Second method in THIS article will help you regarding how to do this