ikwillem ikwillem - 2 months ago 6x
C# Question

Controller redirect to "file.myextention" returns "file.zip" (C# MVC4)

I created a new file extention for a custom client application. The file is actually a zip file with some key files in them, I just renamed it to ".myextention". (like Word and the DOCX extention)

The file is generated on a website, where I have problems downloading the file.

I create the zipfile directly in the "~/Content/" folder, so the client can download it directly and I can re-use the created files. Once created, I redirect the client to this file so their browser automaticly starts downloading the file.

This all works fine, but what the browser is downloading is a ".zip" file, instat of the ".myextention" file.

If I then look with the file-explorer inside the "~/Content/" folder, I find the file in the proper extention and all looks fine.

So some how IIS is renaming my "file.myextention" file to "file.zip".

enter image description here


Add to web.config:

  <mimeMap fileExtension=".myextention" mimeType="application/octet-stream" />

Did the job...