在我的MVC项目中,我有一个文件库。其中有一些文件来自特定的文件夹。当我单击链接进行下载时,找不到某些文件,但文件在那里。
例如:我在content / test.jpg和content / test2.zxd中有两个文件
当我单击mywebsite.com/content/test.jpg时,我可以下载它,但是当我单击mywebsite.com/content/test2.zxd时,我不能下载它。
图像,视频,声音文件,办公文件等。众所周知的扩展名可以正常工作,但是其他文件扩展名会引起问题。我该如何解决?上传之前,我应该压缩它们吗?
我假设您在IIS上使用ASP.NET:也许您必须在register unknown static content files for IIS中使用特定的MIME类型来输入web.config
,例如:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
<remove fileExtension=".zxd" />
<mimeMap fileExtension=".zxd" mimeType="application/octet-stream" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>