In my asp.net, MVC application we are generating and downloading .xlsx file. But when I am trying to open, it's giving a message
"The file you are trying to open, 'filename.xlsx', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" If I press 'Yes' it's opening. I changed the file extension to .xls, still same message. Can anyone tell me why this is happening? I've added .xlsx & .xls MIME type extension in IIS manager with MIME Type as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Still it's showing the same message. Please suggest how can I get rid off it.
Please find my existing code lines for the same -
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; // Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=" + "Survey Report.xlsx");
It's different because there is no any answer specific to this question.