在asp.net文件下载之后就再也没有回传 [英] no more postback after file download in asp.net

查看:108
本文介绍了在asp.net文件下载之后就再也没有回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从网页下载文件后,我不能这样做网页上任何东西。它像网页无法工作了。当我点击另一个按钮,没有回发。

After downloading a file from a webpage, I can't do anything on that page. It is like the page is not working anymore. When I click on other button, there is no post back.

下面是我的代号。

filename= "test.txt"
Response.AppendHeader("content-disposition", "attachment; filename= " + fileName);
Response.WriteFile(Server.MapPath("~/" + fileName));
Response.End();

所以我试评到Response.End()但它仍然没有工作。

还有什么能可能出现的问题?

What can be the possible problems?

更新

<一个href=\"http://stackoverflow.com/questions/7749393/no-more-post-back-after-file-download-in-sharepoint\">Go这个链接,看我如何解决它。

推荐答案

尝试使用 Response.BinaryWrite(字节[])方法。

filename= "test.txt";
byte []bytes=System.IO.File.ReadAllBytes(MapPath("~/" + filename));
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Type","application/octet-stream");
Response.AddHeader("Content-Length",bytes.Length.ToString());
Response.AddHeader("content-disposition", "attachment; filename= " + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();

这篇关于在asp.net文件下载之后就再也没有回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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