尝试下载文件时未找到该网址的网页

No webpage was found for the web address when trying to download file

我有以下结构:

 AppName
    Content
       img
         file.png

我可以直接导航到 mysite.com/Content/img/file.png,没有任何问题。

然而,当我将 test.txt 添加到 img 并设置为 Copy Always 并键入 Content(与 file.png 相同)时,我得到 No webpage was found for the web address 在访问 link 时,当我希望能够让人们下载可公开访问的文件(无需授权)时,就像图像一样。为什么这不起作用?

我可以在应用程序的 bin 文件夹中看到 test.txt。是否需要配置其他内容以启用直接文件下载?

确保您的 IIS 站点设置或web.config具有与 .txt 扩展名关联的 MIME 类型。

https://www.iis.net/configreference/system.webserver/staticcontent/mimemap