I am overriding Render like this:
protected override void Render(HtmlTextWriter writer)
{
var keyCheck = HttpContext.Current.Session["PaymentSearchResults"];
if (_exportToExcel && keyCheck != null)
{
ExportToExcel();
return;
}
base.Render(writer);
}
To download an Excel file which I’m adding to the response like this inside the ExportToExcel method:
File.WriteAllBytes(tempFileName, buffer);
Response.ContentType = "application/ms-excel";
Response.WriteFile(tempFileName);
HttpContext.Current.ApplicationInstance.CompleteRequest();
However, the response is never getting back to the browser and so the browser just hangs.
What am I doing wrong?
This is what i use, in a button click event. works like a charm.