【问题标题】:Mobiles: downloading docx files, sometimes there is an error showing up that the file is corrupted手机:下载 docx 文件,有时会显示文件已损坏的错误
【发布时间】:2015-09-07 11:53:40
【问题描述】:

在我的应用程序中,当用户完成链接时,我们有一个通知功能。该通知将包含存储在服务器上的文件的链接。在发送通知时,我正在准备这样的文件链接

<a href='LINKTOFILEOnSERVER'>FileName</a>

这也是here所说的

现在,在上面的帖子中有设置"content-type""Content-Disposition" 的要点,但我不确定如何在我的情况下设置它。

有人可以帮忙吗?

【问题讨论】:

    标签: asp.net content-type content-disposition mobile-browser


    【解决方案1】:

    为文件提供服务的网络服务器需要设置这些标头。您不能在锚元素中设置它们。

    如果文件是静态的(物理上位于磁盘上),对 IIS 执行此操作的一种方法是为到达文件所在文件夹的所有请求设置 HTTP 响应标头:

    <configuration>     
      <!--set custom headers for "docs" folder -->
      <location path="docs">
        <system.webServer>
          <httpProtocol>
            <customHeaders>
              <add name="Content-Disposition" value="attachment; filename=&quot;file.docx&quot;"/>
              <add name="Content-Type" value="application/octet-stream" />
            </customHeaders>
          </httpProtocol>
        </system.webServer>
      </location>    
    </configuration>
    

    【讨论】:

    • 您的意思是必须在 IIS 中进行设置,对吗?如果是,那么请告诉我这里需要什么?
    猜你喜欢
    • 1970-01-01
    • 2020-08-29
    • 2013-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 2020-12-29
    相关资源
    最近更新 更多