asp .net core静态文件资源的深入讲授
app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "Static")), RequestPath = "/static", OnPrepareResponse = ctx => { ctx.Context.Response.Headers.Append("cache-control", $"public,max-age={cacheMaxAge}"); }, ServeUnknownFileTypes = true, DefaultContentType = "image/png" } ); ServeUnknownFileTypes true DefaultContentType "image/png" 让客户端凭证图片处理赏罚。 可是官方给了提议。 启用 ServeUnknownFileTypes 会形成安详隐患。 它默认处于禁用状态,不提议行使。 FileExtensionContentTypeProvider 提供了更安详的更换要领来提供含非尺度扩展名的文件。 (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |