I know its very old question but may be helpful for others...
The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed.
Instead of Response.End()
, use HttpContext.Current.ApplicationInstance.CompleteRequest()
string excelXml = GetExcelXml(dsInput, filename);
filename=" + filename);
Source: Microsoft official website