Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-10-20
4
Medium Priority
?
1,081 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Screencast - Getting to Know the Pipeline

810 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