Reading the ASP.NET_SessionID Cookie value from an ASP>Net web service

Posted on 2006-10-20
Last Modified: 2010-08-05
I have used the following article to maintain sessions in a web service :

using the following code I would like to read the value (SessionID) that is set in the cookie returned in the web service result.

Private Cookies As System.Net.CookieContainer

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim proxy As New localhost.Service1()
    Dim ret As Integer
    ' Set the Cookie Container on the proxy
    If Cookies Is Nothing Then
        Cookies = New System.Net.CookieContainer()
    End If
    proxy.CookieContainer = Cookies
    ret = proxy.IncrementSessionCounter()
    Label1.Text = "Result: " & CStr(ret)
End Sub

after the web service comes back I can see that Cookies.Count gets set to 1 but I can't find a way to read the cookie value.

please help
Question by:webprouk
  • 2

Expert Comment

ID: 17773927

Accepted Solution

nepali earned 500 total points
ID: 17774707
Try this ..
If the your webservice url is

   Dim z1 As New localhost.zzz()
        ' Set the Cookie Container on the proxy
        If Cookies Is Nothing Then
            Cookies = New System.Net.CookieContainer
        End If
        z1.CookieContainer = Cookies
        Dim uri1 As New Uri("")
        For Each zzzcookie As System.Net.Cookie In z1.CookieContainer.GetCookies(uri1)

Author Comment

ID: 17774846
this gets the cookie info of the web page - not the cookie info sent from the web service.

Author Comment

ID: 17775303
thanks a lot nepali, that did the trick

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now