How can i get the value of a session variable inside a static method in c#?
Posted
by Pandiya Chendur
on Stack Overflow
See other posts from Stack Overflow
or by Pandiya Chendur
Published on 2010-04-05T06:24:38Z
Indexed on
2010/04/05
6:33 UTC
Read the original article
Hit count: 424
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...
© Stack Overflow or respective owner