0

In my c#.NET MVC application you can download an excel file (with the Nuget EPPlus). To send the file to user I set content type as it follows:

System.Web.HttpContext.Current.Response.ContentType = "application/vnd.xls";

What is the difference with:

System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

Which one should I use?

J. Lavoie
  • 335
  • 2
  • 5
  • 23
  • 1
    Neither are correct for XLSX files... See the linked question for the correct values. – David Jun 20 '17 at 19:05
  • 1
    I don't think "application/vnd.xls" has ever been the correct value. Your 2nd option is correct for the older XLS format. – David Jun 20 '17 at 19:12
  • Thank you for the answers, "application/vnd.xls" is working but the format was kind of weird so I was wondering – J. Lavoie Jun 20 '17 at 19:14
  • 1
    Try using System.Web.MimeMapping.GetMimeMapping(yourFileName) to get MIME types - much better than hard-coding strings. – Pete Jun 21 '17 at 12:01
  • @Pete This should be the answer – J. Lavoie Jun 21 '17 at 12:49

0 Answers0