日期:2014-05-19  浏览次数:20457 次

一段下载代码的问题?调试可以,放到IIS上就不行?怎么回事?
代码如下
String     FullFileName   =   "f:\\RISING.rar ";
               
FileInfo   DownloadFile   =   new   FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer   =   false;
Response.ContentType   =   "application/octet-stream ";
Response.AppendHeader( "Content-Disposition ",   "attachment;filename= "   +   HttpUtility.UrlEncode(DownloadFile.FullName,   System.Text.Encoding.UTF8));
Response.AppendHeader( "Content-Length ",   DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
在调试的时候没有问题,可以下载,可是放到IIS中就不行了,提示:
服务器应用程序不可用  
您试图在此   Web   服务器上访问的   Web   应用程序当前不可用。请点击   Web   浏览器中的“刷新”按钮重试您的请求。  

管理员注意事项:   详述此特定请求失败原因的错误信息可在   Web   服务器的系统事件日志中找到。请检查此日志项以查明导致该错误发生的原因。  


------解决方案--------------------
FileInfo DownloadFile = new FileInfo(FullFileName);
这句放到iis里面没有权限执行,你要放到你的虚拟目录下,使用只读属性打开
------解决方案--------------------
权限问题吧
------解决方案--------------------
在源代码路径的权限中,加下Asp.Net user应该就可以了!
------解决方案--------------------
没有权限,要放在网站的目录下,最好这样写成这样的形式
String FullFileName = Server.MapPath( "/downloadfiles/RISING.rar ");
------解决方案--------------------
up