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.
Recommended action
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for