日期:2014-05-18  浏览次数:20638 次

帮忙看看,导出文件的问题。高分!
使用如下的方式导出Excel文件:
System.Web.HttpResponse   currentResponse   =   System.Web.HttpContext.Current.Response;
currentResponse.Clear();  
currentResponse.Buffer=   true;  
currentResponse.Charset= "utf-8 "; currentResponse.AppendHeader( "Content-Disposition ", "attachment;filename= "   +   fileName   );
currentResponse.ContentEncoding=System.Text.Encoding.GetEncoding( "utf-8 ");
currentResponse.ContentType   =   "application/ms-excel ";
currentResponse.Write(outputContent);
currentResponse.end();
如果在IE中不登录,可以导出并打开(通过弹出的对话框中选择Open按钮),但如果使用用户登录进去,就不能打开,但可以保存。用户管理基于DNN(DotNetNuke)框架。各位大虾帮忙分析一些。不胜感激!

------解决方案--------------------
这与登录与否应该是没有关系吧?
------解决方案--------------------
和IE的版本和操作系统的安全机制相关.
------解决方案--------------------
关注,帮顶了
------解决方案--------------------
你的程序看不出什么问题


文件路径是不同的,都是临时文件,我没有指定路径。
=============================================
就从你的文件路径调查入手
断点调试

------解决方案--------------------
"不能打开 " 是什么概念? 下载框中[打开]按钮是灰的?
------解决方案--------------------
给你段代码,一定没有问题,我用过很多次了
protected void ReadFile(string filename)
{


if (filename != " ")
{

string path = Server.MapPath( "upload ")+ "\\ "+filename;

System.IO.FileInfo file = new System.IO.FileInfo(path);

if (file.Exists)
{

Response.Clear();

//Response.AddHeader( "Content-Disposition ", "attachment; filename= " + file.Name);

Response.AppendHeader( "Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(file.FullName, System.Text.Encoding.UTF8));
Response.AddHeader( "Content-Length ", file.Length.ToString());

Response.ContentType = "application/octet-stream ";

Response.Filter.Close();

Response.WriteFile(file.FullName);


Response.End();

}

else
{

Response.Write( "This file does not exist. ");

}

}
}
------解决方案--------------------
还原IE默认设置,
适当调整IE安全级别,
到另一台计算机尝试相同操作.
...
------解决方案--------------------
没弄过这玩意儿.
------解决方案--------------------
你的代码没有1点跟登录有关的东西啊,应该跟登录没关系吧!!!
------解决方案--------------------
路径问题
------解决方案--------------------
权限问题
------解决方案--------------------
...呵呵

这个是客户端的问题

你点打开,然后就下载,然后出现找不到文件,
因为临时文件已经不存在了