Solved

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

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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service08062002.asp

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
0
Comment
Question by:webprouk
  • 2
4 Comments
 
LVL 4

Expert Comment

by:hclgroup
ID: 17773927
0
 
LVL 7

Accepted Solution

by:
nepali earned 500 total points
ID: 17774707
Try this ..
If the your webservice url is
http://127.0.0.1/TestSessionState/zzz.asmx

   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("http://127.0.0.1/TestSessionState/zzz.asmx")
        For Each zzzcookie As System.Net.Cookie In z1.CookieContainer.GetCookies(uri1)
            Debug.WriteLine(zzzcookie.Value)
        Next
0
 
LVL 1

Author Comment

by:webprouk
ID: 17774846
this gets the cookie info of the web page - not the cookie info sent from the web service.
0
 
LVL 1

Author Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

803 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