i have done minor change and now things are working fine.
Use Response.End(); instead of
HttpContext.Current.ApplicationInstance.CompleteRequest();
protected void btnExport_click(object sender, EventArgs e)
{
try
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=iQuiz.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
// HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception ex)
{ }
finally
{ }
}