您如何从Web方法中读取本地资源?

时间:2014-04-10 01:14:56

标签: c# asp.net webmethod

我有以下项目结构:

enter image description here

我的网络方法在文件" 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.

感谢您的解决方案。

1 个答案:

答案 0 :(得分:0)

  

您无法使用HttpContext.GetLocalResourceObject代替该用途   HttpContext.GetGlobalResourceObject

此问题先前已在此处回答:

Asp.Net localization of text in webservice method