This configuration is for the web server, not for ASP.NET. The system.webServer
section in the web.config deals with the configuration of IIS.
If your ASP.NET Core application is running behind IIS and IIS is handling the static content, then you should continue to use the same thing.
If you are using nginx, you can add mime types to your configuration or edit the mime.types
file. If you are using a different web server, consult the documentation for the web server.
If ASP.NET Core is handling the static content itself and is running at the edge, or if you need ASP.NET Core to be aware of mime types, you need to configure ASP.NET Core's handler to be aware of it. This is explained in the documentation.
An example from the documentation:
public void Configure(IApplicationBuilder app)
{
var provider = new FileExtensionContentTypeProvider();
// Add new mappings
provider.Mappings[".myapp"] = "application/x-msdownload";
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "images")),
RequestPath = "/StaticContentDir",
ContentTypeProvider = provider
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…