【在线等】C#下载功能出了问题,请指教!

BEIDOUJS 2011-05-13 07:27:43
在页面中添加一个button按钮实现下载功能,这个button是放在UpdatePanel控件(此处有局部刷新功能)中的,我要下载的资源在我项目的VideoSource文件夹下,后台代码为
 protected void DownLoadButton_Click(object sender, EventArgs e)
{
string fileName = _sourcename;//客户端保存的文件名
string str = _videoUrl;
string[] strFen = str.Split('/');
string filePath = Server.MapPath("VideoSource/" + strFen[1]);//路径
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile("VideoSource\\" + strFen[1]);
Response.Flush();
Response.End();
}

我打断点监视了一下filePath变量,路径是"D:\\CLSoftWare\\NewNetText\\VideoSource\\CSharpDenglu1.wmv"
跳出这个循环以后它会显示如下错误:
Microsoft JScript 运行时错误: Sys.WebForms.PageRequestManagerTimeoutException: 服务器请求超时。
这是怎么回事呀?请高人指点
...全文
118 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wr_ring 2011-07-12
  • 打赏
  • 举报
回复
scriptManager 有AsyncPostBackTimeout 属性,将其超时时间设置长点就好了
BEIDOUJS 2011-05-14
  • 打赏
  • 举报
回复
我是放在一个UpdatePanel控件中的,需要调用JScript,最终是错误也是出现在JScript里,现在不放在UpdatePanel中功能就正常了。
threenewbee 2011-05-13
  • 打赏
  • 举报
回复
Response.WriteFile("D:\\CLSoftWare\\NewNetText\\VideoSource\\CSharpDenglu1.wmv");
可以么?

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧