I am using ASP.NET page methods with jQuery.... How do I get the value of a session variable inside a static method in C#?
protected void Page_Load(object sender, EventArgs e)
{
Session["UserName"] = "Pandiya";
}
[WebMethod]
public static string GetName()
{
string s = Session["UserName"].ToString();
return s;
}
When I compile this I get the error:
An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Session.get'`
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…