'Can not find "locale.properties" file from PDF.js

I use this plugin: PDF.js.

I am trying to solve the problems that show in console log.

Follow image:

enter image description here

Here is a simple project ready, only download and run project you will see the same problem. I've tried everything and I can not solve a problem.

Follow html:

<div style="width: 800px; height: 500px;">
    <iframe width="800" height="500" id="iframePdfViewer" seamless="seamless" scrolling="no" src="~/Scripts/pdfjs-dist/web/viewer.html"></iframe>
</div>

See another image that contains "locale.properties" file:

enter image description here

And I also get a lot of warnings from l10n.js. I downloaded it here: http://mozilla.github.io/pdf.js/ by clicking the "download" button.

Any solution ?



Solution 1:[1]

Adding .properties MIME type configuration inside web.config file should work:

<configuration>
  <!-- other stuff -->

  <system.webServer>
     <staticContent>
        <mimeMap fileExtension=".properties" mimeType="application/octet-stream" />
     </staticContent>
  </system.webServer>
</configuration>

If the project is already deployed in IIS (not IIS Express), go to site name => MIME Types => Add, and set .properties extension with application/octet-stream type as in provided image below:

MIME Type Setting

Here is the console log view with all l10n.js errors disappear:

Console Result

The reason behind usage of application/octet-stream is that the corresponding file should be treated as stream, even file contents are readable and stored in text format.

Reference: l10n.js - locale.properties 404 (Not Found)

Solution 2:[2]

If you are using .net core (2.1) try to add .properties as static file in your "public void Configure(IApplicationBuilder app, IHostingEnvironment env)" method

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".properties"] = "application/octet-stream"; 

app.UseSpaStaticFiles(new StaticFileOptions
{
      ContentTypeProvider = provider
});

Solution 3:[3]

Inspired by Lukáš Jane?ek, If you are using .net core(3.1). try to add the following code to your public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".properties"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions()
{
     ContentTypeProvider = provider
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tetsuya Yamamoto
Solution 2 Lukáš Jane?ek
Solution 3 user18911124