When hosting APK files on IIS 7.0, users often encounter HTTP 404.3 errors because the server doesn't recognize the .apk extension by default. This occurs due to missing MIME type configuration, which tells IIS how to handle specific file types.
Here's how to properly configure IIS 7.0 to serve APK files:
1. Adding the MIME Type
Open IIS Manager and follow these steps:
1. Select your server in the Connections pane 2. Double-click "MIME Types" 3. Click "Add..." in the Actions pane 4. Enter: - File name extension: .apk - MIME type: application/vnd.android.package-archive 5. Click OK
2. Verifying Handler Mappings
Ensure the StaticFile handler is enabled for APK files:
1. Go to "Handler Mappings" 2. Check if "StaticFile" handler exists 3. If missing, add it with the following configuration: - Request path: * - Type: File - Modules: StaticFileModule - Executable: (leave empty) - Name: StaticFile
For production environments, consider these additional settings:
Web.config Example
You can also configure this via web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
</configuration>
Security Considerations
When serving APK files:
- Set proper Content-Disposition headers to force download
- Implement authentication if serving private APKs
- Consider adding virus scanning for uploaded APKs
If APK downloads still don't work:
- Clear the IIS configuration cache:
iisreset
- Check file permissions on the APK file
- Verify the MIME type was added at the correct level (server vs site)
When hosting APK files on IIS 7.0, the web server needs explicit configuration to recognize the .apk
file extension and serve it with the correct MIME type. Without proper configuration, IIS will either block the download or serve the file with an incorrect content type.
The primary solution involves adding a MIME type mapping in IIS. This can be done either through:
1. IIS Manager GUI:
- Open IIS Manager
- Select your server or site in the Connections pane
- Double-click "MIME Types"
- Click "Add..." in the Actions pane
- Enter:
File name extension: .apk
MIME type: application/vnd.android.package-archive
- Click OK
2. Web.config (for automated deployments):
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
</configuration>
Security Implications: APK files are executable packages. Ensure proper authentication/authorization is configured if hosting sensitive applications.
HTTP Headers Verification: After configuration, verify the server is sending correct headers using browser developer tools or curl:
curl -I http://yourserver.com/yourapp.apk
The response should include:
Content-Type: application/vnd.android.package-archive
403 Forbidden Errors: If you see this after MIME configuration, check:
- File system permissions (IIS_IUSRS needs read access)
- Request filtering settings (some servers block executable downloads by default)
Case Sensitivity: IIS 7.0 is case-sensitive for extensions. Consider adding both .apk
and .APK
mappings if your deployment environment varies.
For large APK files, consider enabling compression and proper cache headers:
<configuration>
<system.webServer>
<urlCompression doStaticCompression="true" />
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
This configuration will compress the APK during transfer and instruct clients to cache the file for 7 days.