Solved

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

Posted on 2006-10-20
4
992 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
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…

707 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

19 Experts available now in Live!

Get 1:1 Help Now