Sessions with web services

J

Joshua Ellul

Hi There,

Could someone tell me how to implement sessions in web services?

I am using the EnableSession property (set to true)... however, the session
is not being maintained... is there something I am missing? Perhaps setting
a session time out? The client of the web service is an asp.net web form.

Thanks,

Josh
 
J

Jan Tielens

To maintain session state:

WebMethodAttribute.EnableSession Property
Indicates whether session state is enabled for an XML Web service method.
http://tinyurl.com/2rs6d

Did you follow following example (see url also)?
<%@ WebService Language="C#" Class="Util" %>

using System.Web.Services;

public class Util: WebService {
[ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
public int SessionHitCounter() {
if (Session["HitCounter"] == null) {
Session["HitCounter"] = 1;
}
else {
Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
}
return ((int) Session["HitCounter"]);
}
}


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top