c# - 你如何从网络方法读取本地资源?

标签 c# asp.net webmethod

我有以下项目结构:

enter image description here

我的 Web 方法在文件“MobileStart.cs”中声明,我需要从文件“start.aspx.resx”中读取资源值。以下是我尝试读取资源值:

[WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static string EmailSurveyLink(string email)
    {
        var response = new StartPageResponse();

        string message = String.Format(HttpContext.GetLocalResourceObject("~/Surveys/start.aspx.resx", "LoginSentEmail", new CultureInfo("en-AU")).ToString(), messageVars);

        return new JavaScriptSerializer().Serialize(response);
    }

当我从客户端调用该方法时出现以下错误:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "start.aspx.resx.resources" was correctly embedded or linked into assembly "App_LocalResources.surveys.cdcab7d2.jsl8asuu" at compile time, or that all the satellite assemblies required are loadable and fully signed.

我将不胜感激,谢谢。

最佳答案

You can't use HttpContext.GetLocalResourceObject instead of that use HttpContext.GetGlobalResourceObject

这个问题之前已经在这里回答过:

Asp.Net localization of text in webservice method

关于c# - 你如何从网络方法读取本地资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22976897/

相关文章:

c# - 一台服务器许多客户端 : Threads or classes

c# - Asp.Net:没有适合 AuthenticationMiddleware 的构造函数

c# - 从 Usercontrol.ascx javascript 调用 Usercontrol.cs 中的 Webmethod

c# - ajax 发送 FormData c# WebMethod

c# - 使用 Linq 排序

c# - 凯撒密码如何同时替换多个字母?

c# - 防止C#中的重复字符串

asp.net - 如何使母版页内容根据角色可见?

asp.net - 负载平衡 Web 服务器上的 Orchard CMS

javascript - 如何使用Angular js将json中的数据绑定(bind)到li