Static files: CSV content type changed to standards-compliant

In ASP.NET Core 5.0, the default Content-Type response header value that the Static File Middleware uses for .csv files has changed to the standards-compliant value text/csv.

For discussion on this issue, see dotnet/aspnetcore#17385.

Version introduced

5.0 Preview 1

Old behavior

The Content-Type header value application/octet-stream was used.

New behavior

The Content-Type header value text/csv is used.

Reason for change

Compliance with the RFC 7111 standard.

If this change impacts your app, you can customize the file extension-to-MIME type mapping. To revert to the application/octet-stream MIME type, modify the UseStaticFiles method call in Startup.Configure. For example:

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".csv"] = MediaTypeNames.Application.Octet;

app.UseStaticFiles(new StaticFileOptions
{
    ContentTypeProvider = provider
});

For more information on customizing the mapping, see FileExtensionContentTypeProvider.

Affected APIs

Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider