如何在ASP.NET AJAX中实现文件下载 [英] How to implement a file download in ASP.NET AJAX

查看:411
本文介绍了如何在ASP.NET AJAX中实现文件下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用标准的ASP.NET文件下载响应,如其他堆栈溢出问题

I would like to use standard ASP.NET file download response, like in other Stack Overflow question.

Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment; filename=logfile.txt");
Response.TransmitFile( Server.MapPath("~/logfile.txt") );
Response.End();

但是在更新面板中,它不起作用。我需要做什么,如果下载事件在更新面板中被触发,我会得到一个文件?

But inside update panel it does not work. What I have to do, that I will get a file if the download event is triggered inside update panel?

推荐答案

嗯,我在Encosia上发现了很好的博客文章,描述了这个ASP.NET AJAX文件下载问题的解决方案。它的工作非常好。

Well, I have found nice blog post on Encosia which describe solution of this ASP.NET AJAX file download problem. It work really nice.

http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/

这篇关于如何在ASP.NET AJAX中实现文件下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆