当前位置:网站首页>. Net core accesses uncommon static file types (MIME types)

. Net core accesses uncommon static file types (MIME types)

2022-07-07 07:00:00 Pingshan CP3

background : Need to be in .net core The access suffix in the website is properties The file of , Discover direct access 404, After consulting colleagues , It needs to be configured .net core Support for accessing static file types , Make a note of

var provider = new FileExtensionContentTypeProvider();
// Add new mappings, take properties The file is mapped to text/html
provider.Mappings[".properties"] = "text/html";
app.UseStaticFiles(new StaticFileOptions
{
    ContentTypeProvider = provider
});

Official documents about the configuration of static files :

ASP.NET Core Static file in | Microsoft Docs Learn how to be in ASP.NET Core Web Provide and protect static files in applications , And how to configure the behavior of static file hosting middleware .icon-default.png?t=M5H6https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/static-files?view=aspnetcore-5.0

原网站

版权声明
本文为[Pingshan CP3]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070248541747.html