发送HTTP标头后无法重定向. [英] Cannot redirect after HTTP headers have been sent.

查看:96
本文介绍了发送HTTP标头后无法重定向.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

生成报告后重定向到新页面.(我必须这样做)

因此,生成了报告,但给了我错误发送HTTP标头后无法重定向.

这是我的代码....

after generate report redirecting to new page.(this i have to do )

so, report is generated but gives me error Cannot redirect after HTTP headers have been sent.

here is my code....

view_report(); //gets records  from database.
       try
       {
           Rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Summary Report");


       }
       catch (Exception ex)
       {
           Console.WriteLine(ex.Message);
           ex = null;
       }
       finally
       {
           Response.Redirect("~/MessagePage.aspx",false);
       }




所以我都想要
生成报告并重定向到新页面.




so i want both
generate report and redirecting to new page.

推荐答案

尝试:
Response.Redirect("~/MessagePage.aspx", false);



此处的详细信息: MSDN:HttpResponse.Redirect方法(字符串,布尔值) [ ^ ]



Details here: MSDN: HttpResponse.Redirect Method (String, Boolean)[^]


这篇关于发送HTTP标头后无法重定向.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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