Problem: How to enable session in web service?
Solution: By default, ASP.NET session support for each Web method is turned off. You need to add EnableSession=true property for the WebMethod attribute.
For example look at the following code snippet:
WebMethod(EnableSession=true)]
public static int SessionCounter()
{
int counter=0;
counter=Convert.ToInt32(Session["Counter"]);
counter++;
return counter;
}
You need to confirm that session state is enabled in web config file.
Solution: By default, ASP.NET session support for each Web method is turned off. You need to add EnableSession=true property for the WebMethod attribute.
For example look at the following code snippet:
WebMethod(EnableSession=true)]
public static int SessionCounter()
{
int counter=0;
counter=Convert.ToInt32(Session["Counter"]);
counter++;
return counter;
}
You need to confirm that session state is enabled in web config file.
No comments:
Post a Comment