System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.Buffer = true;
response.Charset = “charset=utf-8”;
response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;
response.AddHeader(“content-disposition”, “attachment;filename=ExcelData.xlsx”);
response.BinaryWrite(File.ReadAllBytes(templateDir + “myFile.xlsx”));
response.Flush();
response.End();
The Excel File that is downloaded after the http request made to the Controller method is corrupted. The data/text is Excel file is not readable and modified. I am using the above mentioned code. Please help me to resolve this issue.