繁体   English   中英

使用Response.TransmitFile()下载文档时出错

[英]Error when downloading document using Response.TransmitFile()

我有一个网页,其中包含允许用户下载文档的链接。 如果用户从物理位置(即C:\\ filename)下载文档以及作为网站的一部分存储的文档(即〜/ Documents / filename),我正在使用的代码有效。

但尝试从网络位置下载文件时它不起作用,并发生以下错误:' Could not find a part of the path '

这是我的代码:

     Response.ContentType = "application/msword";
        Response.AppendHeader("Content-Disposition", "attachment; filename=filename.doc");
        Response.TransmitFile(Server.MapPath(@"\\ad.website.com\public\shared\filename.doc"));
        Response.End();

我已经研究过这个错误,它似乎可能是由权限或IIS设置引起的。 是这种情况还是我需要更新代码?

你应该从该位置删除Server.MapPath ..
另外,它会尝试匹配当前服务器的路径。

暂无
暂无

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

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