.net 6 mvc 使用pdf.js 中pdfjs-4.3.136-dist/web/viewer.html 加载pdf时,无法加载locale文件夹下面的.ftl文件

修改program.cs 代码如下:

app.UseStaticFiles(new StaticFileOptions
{
   FileProvider = new PhysicalFileProvider(
   Path.Combine(app.Environment.ContentRootPath, "wwwroot")),
   ServeUnknownFileTypes = true, // 允许浏览具有未知MIME类型的文件
   DefaultContentType = "text/plain", // 如果无法确定MIME类型,则默认为纯文本
   OnPrepareResponse = ctx =>
   {
       if (Path.GetExtension(ctx.File.PhysicalPath).Equals(".ftl"))
       {
           ctx.Context.Response.ContentType = "application/octet-stream";
       }
   }
});
posted @ 2024-06-12 13:18  黄小7  阅读(333)  评论(0)    收藏  举报