定向到一个新的页面下载文件后 [英] Directing to a new page after downloading a file

查看:99
本文介绍了定向到一个新的页面下载文件后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试下载它不工作文件后重定向到新的一页。我一定要删除或修改此code什么?调试犯规达到它

 字节[] = FILEDATA(字节[])sqlRead [3];Response.Clear();
Response.AppendHeader(内容处置,附件;文件名=+ sqlRead [2]);
Response.ContentType =应用程序/八位字节流;
Response.BinaryWrite(FILEDATA);Response.Flush();
到Response.End();
Response.Clear();的Response.Redirect(Questions.aspx);


解决方案

安德鲁是对的到Response.End停止执行。我不认为删除它会有所帮助,但是,因为它只是影响你要发送的文件。

您可以得到你想要与其他招数的效果。例如,你可以在网页上使用一些JS与DL链接做一个客户端的重定向。

修改

什么我建议是,你增加一个次要的行为到您的下载链接,这样点击它都下载该文件,并改变了当前页。它可能会更好地工作,如果点击启动定时器,做在第二个左右的重定向。

When I try to redirect to a new page after downloading a file it doesn't work. Do I have to remove or modify anything in this code? the debugger doesnt reach it

byte[] fileData = (byte[])sqlRead[3];

Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" + sqlRead[2]);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(fileData);

Response.Flush();
Response.End();
Response.Clear();

Response.Redirect("Questions.aspx");

解决方案

Andrew is right about Response.End stopping execution. I don't think that removing it will help, though, since it would just affect the file you're sending.

You can get the effect you want with other tricks. For example, you could use some JS on the page with the DL link to do a client-side redirect.

edit

What I'm suggesting is that you add a secondary behavior to your download link so that clicking on it both downloads the file and changes the current page. It might work better if clicking starts a timer that does the redirect in a second or so.

这篇关于定向到一个新的页面下载文件后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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