Tuesday, March 8, 2011

How to use Session variable in Asp.net web service

In order to use Session variable in asp.net web service you need to add
EnableSession=true attribute in web method definition.

[WebMethod(EnableSession=true)]
public void HelloUser()
{
return "Hello " + Convert.ToString(Session["LoggedInUser"]);
}