Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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);
Posted
Updated 9-Aug-15 21:22pm
v2
Comments
DamithSL 10-Aug-15 2:59am    
can you update the question with related code?

1 solution

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


C#
HttpContext.Current.Response.Write(executionResult.Stream.ToString());
HttpContext.Current.Response.End();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900