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();