.Net Core/.Net 6/.Net 8 添加MIME类型
在
Program.cs
app.UseStaticFiles
这样写
csharp
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".apk"] = "application/vnd.android.package-archive";
provider.Mappings[".flac"] = "audio/flac,audio/x-flac";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider,
OnPrepareResponse = (c) => {
c.Context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
}
});