如何在静态方法中使用 LocalResourceObject [webmethod]

0 c# asp.net static localization webmethod

我可以简单地在 aspx 页面中使用本地化,但不能在 aspx.cs 文件中使用。

 [WebMethod]
    public static string Menu(int role, int driver)
    {
 string _permissions = dr["FN_2"].ToString().Replace(" /V*", System.Web.HttpContext.GetLocalResourceObject("CRL.aspx", "RV.Text").ToString());
// This way didn't get error in coding but when I run it, give me no permission error for virtual path

string _permissions = dr["FN_2"].ToString().Replace(" /V*", System.Web.HttpContext.GetLocalResourceObject("RV.Text").ToString());
//I cannot use in this way
    }
Run Code Online (Sandbox Code Playgroud)

在aspx页面中,我可以这样称呼它GetLocalResourceObject("RV.Text")。我必须接触这些本地化的东西,我需要它们做很多事情。

我无法通过这两种方式从 localresource 对象返回文本。其中一个在编码时出错,另一个由于权限无法到达虚拟路径。我如何使用GetLocalResourceObject[WebMethod]

小智 5

你可以这样使用: string _permissions = HttpContext.GetLocalResourceObject("~/×××/×××.aspx", "RV.Text").ToString();