willthiswork89
willthiswork89

Reputation: 617

MVC returning .apk file without extension

This one has me stumped. Within our controller we have a path called ~/AppAndroidPackage

This url will grab the latest version of an APK for us and return the content in an actionresult, specifically a FileContentResult.

 FileContentResult res = File(file.Data, file.ContentType, file.DownloadName);

file.ContentType is "application/vnd.android.package-archive"
file.DownloadName is "App.apk"

When attempting to download chrome gives the warning:

"Resource interpreted as Document but transferred with MIME type application/vnd.android.package-archive"

The actual file that is downloaded is "AppAndroidPackage" with no extension. Simply adding ".apk" through the file system fixes the issue but obviously this is not ideal when on the phone.

I've added the MIME type ".apk" to IIS and the issue remains.

Any help would be appreciated!

Upvotes: 0

Views: 1177

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239270

That particular Chrome error usually means that an error page was returned, instead of the file you intended. For example, if your action raised an exception, a response with a 500 status code will be returned with the HTML content of your 500 error page. Obviously that is not an APK, so Chrome notifies you in this way. I'd check that your action is returning correctly with no errors.

Upvotes: -1

Related Questions