【问题标题】:Asp.net MVC .properties file is not loading from View(cshtml)Asp.net MVC .properties 文件未从 View(cshtml) 加载
【发布时间】:2016-10-22 06:43:21
【问题描述】:

我正在做一个 asp.net mvc 项目。在 view(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文件吗?
  • 我不确定.....文件名是'locale',扩展名是'properties' 这是该文件中的两行,[ach] @import url(ach/viewer.properties ) 这个文件自己导入了很多属性文件。
  • 确保您的 web.config 中有以下代码块 &lt;system.webServer&gt; &lt;staticContent&gt; &lt;remove fileExtension=".application" /&gt; &lt;mimeMap fileExtension=".application" mimeType="application/octet-stream" /&gt; &lt;/staticContent&gt; &lt;/system.webServer&gt;

标签: asp.net-mvc razor


【解决方案1】:

您必须将.properties 文件扩展名添加到您的web.config 文件中:

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

【讨论】:

    猜你喜欢
    • 2011-12-01
    • 1970-01-01
    • 2022-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多