I know this kind of questions are asked lot many times on lot many forums but the thing make this issue stranger is, its working for one module on both local and server but not for anotherone.
Let me be more clear.
I am exporting an excel sheet for one module, say CS using following code
public void ExportToExcel(string fileName, GridView gv)
{
try
{
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xls", fileName));
HttpContext.Current.Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
}
}
and exporting another list say, retailer with same code. I debugged on local and for second module it was giving an exception
ThreadAbortException
but one record list.
as suggested here I used HttpContext.Current.ApplicationInstance.CompleteRequest
but getting unexpected result (whole page is expoted)