简体   繁体   中英

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".

在此输入图像描述

Add to web.config:

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

Did the job...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM