Asp.net MVC中的.properties文件未能从视图(cshtml)加载

4
我正在进行一个asp.net mvc项目。在视图(cshtml)页面中,我需要加载几个具有不同扩展名的外部资源。所有扩展名为.css.js的资源都已经被加载了。但是,一个扩展名为.properties的文件在相同的过程中没有被加载。我不知道如何解决这个问题。
错误信息为 - 无法加载资源:服务器响应状态为404(未找到) 我的项目结构如下:
-Project
    -Areas
        -Two
            -Library
                -pdfjs-1.5.188-dist
                    -web
                        -locale
                            -locale.properties

我在视图中使用以下代码加载locale.properties文件:

<link rel="resource" type="application/l10n" href="~/Areas/Two/Library/pdfjs-1.5.188-dist/web/locale/locale.properties">

给定的路径是100%正确的。但是,在该路径上未找到资源。

有人可以告诉我问题出在哪里,以及我该如何解决?


那是一个Java文件吗? - Cristian Szpisjak
我不确定......文件名是“locale”,扩展名是“properties”。这个文件中有两行,[ach] @import url(ach/viewer.properties)这个文件会导入许多属性文件。 - ishmam shahriar
请确保您的web.config文件中包含以下代码块:<system.webServer> <staticContent> <remove fileExtension=".application" /> <mimeMap fileExtension=".application" mimeType="application/octet-stream" /> </staticContent> </system.webServer> - Cristian Szpisjak
1个回答

5

你需要将 .properties 文件扩展名添加到你的 web.config 文件中:

<system.webServer>
  <staticContent>
    <remove fileExtension=".properties" />
    <mimeMap fileExtension=".properties" mimeType="text/plain" />
  </staticContent>
</system.webServer>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接