我有一个网页,其中包含一个链接,让用户下载一个文件。如果用户从物理位置(即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设置引起的。是这样呢,还是我需要更新代码?
发布于 2012-07-02 18:27:23
您应该从该位置删除Server.MapPath。
否则,它将尝试仅匹配到当前服务器的路径。
https://stackoverflow.com/questions/11291818
复制相似问题