使用方法“发送文件" )(VS2010 – C#) [英] my button Don’t Redirect after use of method " TransmitFile" ) (VS2010 – C#)
本文介绍了使用方法“发送文件" )(VS2010 – C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
要下载文件,请使用以下代码:
Hi
For download a file I use below code:
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
String FilePath = @"~\myfolder\myfile.pdf";
HttpContext context = HttpContext.Current;
context.Response.AppendHeader("content-disposition", "attachment; filename= myfile.pdf");
context.Response.ContentType = "application/ZipFile";
context.Response.TransmitFile(FilePath);
}
else
{
}
但是执行此操作后,下面的代码(重定向到另一个页面"的按钮)将无法运行.为什么?
But after do it , below code (a button for Redirect to another page) don’t operate. Why?
try
{
Response.Redirect("~/myfolder/mypage2.aspx?returnUrl= mypage1.aspx");
}
catch
{
}
非常感谢
Thanks very much
推荐答案
试试这个
Hi ,
Try this one
try
{
Response.Redirect("~/myfolder/mypage2.aspx?returnUrl= mypage1.aspx",false);
}
最好的问候
米特瓦里(M.Mitwalli)
Best Regards
M.Mitwalli
这篇关于使用方法“发送文件" )(VS2010 – C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文