Response.End() throws an error when exporting excel in c#

Instead of Response.End() use,

Possible Solution1:
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();


Note1: Response.End is a bad practice, it aborts the thread to bypass the rest of the operations in the http request lifecycle and it throws an exception

Possible Solution2:
Also try by giving value "true" in Response.End()
 
 
Possible Solution3:
Replace Response.End() with HttpContext.Current.Response.End();

Comments

Popular posts from this blog

Run Powershell script on Remote Computer/Server

SPDActivities - DP.SharePoint.Workflow - Workflow failed to run

Volatile function error for SharePoint calculated field current date