繁体   English   中英

ASP.NET WebForms:为什么我不能下载通过应用程序上传的某些文件?

[英]ASP.NET WebForms: Why can't I download certain files that I've uploaded through my application?

我有一个简单的asp:FileUpload控件,可将文件保存到服务器。 它将文件保存到磁盘,然后在数据库中创建对该文件的路径引用。 我们使用以下标记将这些文件显示在DataGrid中:

<ItemTemplate>
    <a href='<%# MyApp.Global_asax.UploadPath + DataBinder.Eval(Container.DataItem, "FolderName") + "/" +  DataBinder.Eval(Container.DataItem, "FileName") %>' target="_blank">
        <%# DataBinder.Eval(Container.DataItem, "FileName") %>
    </a>
</ItemTemplate>

因此,如您所见,这没什么特别的。 但是,尝试下载一些文件会导致IE9中出现此消息:

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

我在FireFox中收到类似的消息。

到目前为止,这仅在.DOTM文件中发生。 我以为可能是文件名,所以我将名称更改为简单的名称,例如xxx.dotm ,但这仍然没有下载。 当我将扩展名更改为TXT ,它的xxx.txt ,我可以下载文件了。

有谁能给我一个关于这里发生的事情的想法?

您需要在IIS中为该文件扩展名添加MIME类型。

对于IIS 6.0:

http://support.microsoft.com/kb/326965

对于IIS 7.0:

http://technet.microsoft.com/zh-CN/library/cc725608(v=ws.10).aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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