【问题标题】:MVC specific files can not download from ftp无法从 ftp 下载 MVC 特定文件
【发布时间】:2020-04-22 23:10:16
【问题描述】:

在我的 MVC 项目中,我有一个文件库。其中有一些文件来自特定文件夹。当我点击链接下载它时,有些文件找不到,但文件在那里。

例如:我在 content/test.jpgcontent/test2.zxd 有两个文件

当我点击 mywebsite.com/content/test.jpg 时,我可以下载它,但是当我点击 mywebsite.com/content/test2.zxd 时,我无法下载它。

图像、视频、声音文件、办公文件等。众所周知的扩展名可以完美运行,但其他文件扩展名会导致问题。我该如何解决这个问题?我是否必须在上传之前对其进行压缩?

【问题讨论】:

    标签: c# asp.net-mvc


    【解决方案1】:

    我假设您在 IIS 上使用 ASP.NET:
    也许您必须在 web.config 中使用特定的 mime 类型来 register unknown static content files for IIS,例如:

    <?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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-13
      • 2014-08-05
      相关资源
      最近更新 更多