How can i get the value of a session variable inside a static method in c#?
- by Pandiya Chendur
I am using asp.net pagemethods with jquery.... How to get the value of a session variable inside 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'
Any suggestion or any alternative...