如何在 static
WebMethod
函数中获取 Page.UICulture
。以下给我一个错误:
Page.UICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
我得到的错误:
An object reference is required for the non static field,method or property
最佳答案
很简单,你不能。
属性 Page
对 static
方法不可用,这是有道理的,因为在该静态 WebMethod
的上下文中,您没有页面。
您可以将相关属性保存在 Session
变量中,并从 WebMethod
中的 session 信息中获取它。请注意,您必须设置 [WebMethod(EnableSession=true)]
才能从 WebMethod
获取 session 信息。
关于c# - 如何在静态 WebMethod 中获取 Page.UICulture?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28408477/