I'm having a Visual Webpart that allows user to select Managed Properties and find out what is stored inside it. The result is displayed inside a gridview which he/she can export it to excel.
It is same another export to excel code that I have written:
HttpContext.Current.Response.Clear(); string filename = "Report_" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss") + ".xls"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + filename); HttpContext.Current.Response.ContentType = "application/ms-excel"; GridView tempGridView = new GridView(); tempGridView.AutoGenerateColumns = false; string strContents = getGridViewHtml(GetExportingGridView(tempGridView)); HttpContext.Current.Response.Write(strContents); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End();
But after the file is downloaded the page stops responding to any events.
I cannot have one more (dummy) page which can take this request and make a download operation and go off.
Any work around for this issue ?