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

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
Who is Participating?
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)
webproukAuthor Commented:
this gets the cookie info of the web page - not the cookie info sent from the web service.
webproukAuthor Commented:
thanks a lot nepali, that did the trick
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.