Search code examples
c#htmlangularjsiiswindows-server-2016

'.heif' file is not downloading, server is returning 404 Not Found error


The anchor link for downloading .heif extension is not working. I'm getting 404 Not Found error but the file is present on the server. The same link is working for every known type of files like 'png, jpeg, pdf, docx etc'. I'm using following anchor tag for downloading of file:

    <a ng-href="{{clientProfile.stdidentityDocObj.payeE_DOCUMENT_FILE}}"
                               target="_blank" download>Download
    </a>

The error I'm getting is: 404 Not Found error

The website is deployed on Windows Server 2016. What could be the issue here? Is there any way that I can be able to download these type of files also?


Solution

  • You need to tell IIS about the file extension, see this doc for more information, but it states:

    IIS 7 will not return file types that are not added to the <staticContent> element or that have mappings in the <handlers> element by default. This behavior prevents unauthorized access to files that do not have mappings in the IIS 7 configuration settings.

    So to fix this, add a staticContent element:

    <configuration>
       <system.webServer>
          <staticContent>
             <!-- Add this line... -->
             <mimeMap fileExtension=".heif" mimeType="application/octet-stream" />
          </staticContent>
       </system.webServer>
    </configuration>