When writing to response object my code is
private void ConvertToExcel(DataTable dt, HttpResponse iResponse)
{
try
{
Response.Clear();
Response.Charset="";
Response.ContentType="application/vnd.ms-excel";
System.IO.StringWriter stringWrite=new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite=new System.Web.UI.HtmlTextWriter(stringWrite) ;
System.Web.UI.WebControls.DataGrid dg=new System.Web.UI.WebControls.DataGrid();
dg.DataSource = dt;
dg.DataBind();
dg.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception ex )
{
ErrorLogger.LogError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurr ...
Go to the complete details ...