Groups | Blog | Home
all groups > asp.net webservices > july 2004 >

asp.net webservices : Cookieless Session and Web Service Problem



localhost
7/28/2004 4:17:50 PM

I am looking for any C# example on using a web service with cookieless
Sessions.

[WebMethod(Description="Help",EnableSession=true)]
public string SessionShow()
{
return HttpContext.Current.Session.SessionID;
}

Gives an error.

lukezhan NO[at]SPAM online.microsoft.com
7/29/2004 3:24:20 AM
Hello,

Regarding the issue, you may take a look at following article:

Using ASP.NET Session State in a Web Service
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/h
tml/service08062002.asp

The auther provide a solution for the issue.

Hope this help,

Luke
localhost
7/29/2004 11:04:40 AM

Thanks, but I had already Googled for that and read it before I posted
my request. The article is old, and also covers VB.NET only.

I did some more investigation on my own, and found this sample to
work. However, I am not sure if I will run into any issues doing
this:

[WebMethod(Description="HeyNow",EnableSession=true)]
public string SessionShow()
{
if ( HttpContext.Current.Session["incrementMe"] == null )
{

HttpContext.Current.Session["incrementMe"] = "x";
}
else
{
HttpContext.Current.Session["incrementMe"] += " x ";
}
return HttpContext.Current.Session.SessionID +
Session["incrementMe"].ToString() + " ";
}

I do see multple " x " values, so I think the Session is sticking, but
I am not sure. What is a good way to test this?

Thanks.









On Thu, 29 Jul 2004 03:24:20 GMT, lukezhan@online.microsoft.com
[quoted text, click to view]
lukezhan NO[at]SPAM online.microsoft.com
7/30/2004 6:12:55 AM
To make sure this, you may have two clients connect the web service at same
time, to see if they can get different value along with their session.

Luke
lukezhan NO[at]SPAM online.microsoft.com
8/3/2004 9:30:04 AM
Hello,

Have you made any progress on the issue? If you still need more
information, please feel free to let us know.

Luke
AddThis Social Bookmark Button