导出到csv仅在生产服务器的底部创建HTML文本 [英] Export to csv creates HTML text at the bottom on production server only
本文介绍了导出到csv仅在生产服务器的底部创建HTML文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试导出到csv,同时这样做HTML页面文本在csv文件中的欲望结果之后呈现。这只发生在生产服务器或QA环境上而不是Dev.Kindly帮助我。
我使用下面的代码
I am trying to export into csv, while doing so HTML text of page is rendered after the desire result in a csv file. This is happening only on production server or QA environment not on Dev.Kindly help me.
I have used below code
this.Page.Response.ContentType ="text/csv";
HttpContext.Current.Response.AddHeader("Content-disposition", string.Format("attachment; filename=report.{0}", "csv"));
HttpContext.Current.Response.AddHeader("Content-Length", executionResult.Stream.Length.ToString());
HttpContext.Current.Response.BinaryWrite(executionResult.Stream);
推荐答案
确保在你的最后一行之后给你写的代码
HttpContext.Current.Response.End();
同样尝试使用HttpContext.Current.Response.Write而不是HttpContext.Current.Response.BinaryWrite
Make sure that after the last line of your give code you have written
HttpContext.Current.Response.End();
As well try using HttpContext.Current.Response.Write instead of HttpContext.Current.Response.BinaryWrite
HttpContext.Current.Response.Write(executionResult.Stream.ToString());
HttpContext.Current.Response.End();
这篇关于导出到csv仅在生产服务器的底部创建HTML文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文