【问题标题】:How to access localised resources in an .ashx file?如何访问 .ashx 文件中的本地化资源?
【发布时间】:2011-04-03 01:41:58
【问题描述】:

我有一个返回本地化消息的 ashx 文件。这是从 Ajax 请求中调用的。我需要访问 ashx 文件中的 Asp.net ResourceManager。

【问题讨论】:

    标签: asp.net localization httphandler asp.net-4.0 ashx


    【解决方案1】:

    以下代码对我有用。

    HttpContext.GetGlobalResourceObject("classKey", "resourceKey") as string;
    

    【讨论】:

      【解决方案2】:

      应用程序中的任何资源都应该可以在 Resources 命名空间下访问。

      对于名为 LocalMessages.en.resx 的资源文件:

      ReturnMsg = Resources.LocalMessages.MyAjaxMessage;
      

      要使智能感知正常工作,请确保应用已编译一次以从 resx 文件创建资源对象。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-19
        • 1970-01-01
        相关资源
        最近更新 更多