Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to download the .7z extension file through application

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

like image 559
NithyaGopu Avatar asked Jun 09 '15 04:06

NithyaGopu


2 Answers

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

like image 150
Lance Avatar answered Nov 10 '22 11:11

Lance


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

like image 31
SteveFerg Avatar answered Nov 10 '22 12:11

SteveFerg