Session("MyName") not working
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.webservices.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Vincent Finn
Hi,

I am trying to store an object in the Session()

I have a VB.Net control which is loaded in an asp page and then calls
a function in my webservice (also written in VB.Net)

The web service function has everything it seems to need the code is
at the bottom of the mail

The MSDN makes some mention of needing to do something on the client
side with regards to cookies but I can't find a decent example

Can anyone tell my what I need for the client side?
or have I done something wrong in the WebMethod?

    Vin

<WebMethod(Description:="Desc", EnableSession:=True)> _
Public Function MyFn()
If (Session("MyName") Is Nothing) Then
Session("MyName") = DateTime.Now()
End If
Dim dt as DateTime
dt = Session("MyName")
End Function

Reply to this message...
 
    
Dino Chiesa [Microsoft] (VIP)
Yes, this is a FAQ.

check http://www.xmlwebservices.cc/index_FAQ.htm
and search for "Session"

-D

"Vincent Finn" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Vincent Finn
On Fri, 3 Sep 2004 14:01:50 -0400, "Dino Chiesa [Microsoft]"
<Click here to reveal e-mail address> wrote:

[Original message clipped]

The FAQ has even less info that the MSDN.

My Web Service side is correct according to both
but neither tell me what to do with the client

They mention enabling and storing cookies but no examples that I can
follow, any sample code assumes your client is as ASPNET app
mine is a user control so I have no CookieContainer

    Vin
Reply to this message...
 
    
Dino Chiesa [Microsoft] (VIP)
Vin,

I cannot figure why you did not find it by searching as I suggested. when I
search for session on that page - I just checked - this is what I get:

++ begin quote ++
The client application' proxy uses the HttpClientProtocol classes which by
default do not know about sessions. Therefore you have to enable cookie
management in the client proxy class by adding code like this in your client
application:
myProxyClass.CookieContainer =
new CookieContainer();

It is important to mention that the session is only valid for a single
client proxy instance.
Of course the sample assumes you have configured your Web Service correctly
to maintain session state (see above).
++ end quote ++

[Original message clipped]

I don't think this is correct, maybe you missed the discussion of the Win
Forms client. But in fact it really doesn't matter if the client is
winforms, webforms, user control, a console app, or something else. If it
is using the .NET-generated proxy helper classes, then you can and should
use a cookiecontainer to make your client "Session aware".

> Vin

-D

Reply to this message...
 
    
Vincent Finn
I am clearly missing something fundamental here

I did search the page and see the section below but it doesn't mean
anything to me, I must be lacking some sort of basic background
knowledge on it.

>The client application' proxy uses the HttpClientProtocol classes

This is where the problem starts
my client is not using HttpClientProtocol
and if I search in the MSDN for the term there are no hits

What is it and how do I enable it?

without the HttpClientProtocol I don't have a CookieContainer so I
can't go any further

[Original message clipped]

Same problem again
How do I get the .Net-generated proxy helper class?

    Vin
Reply to this message...
 
    
Dino Chiesa [Microsoft] (VIP)
how do you get the client-side proxy?
Do you use wsdl.exe ? or possibly VS.NET "Add Web Ref" ?

In either case you generate the client-side proxy class. Depending on which
protocol is supported by the service, you will get a different base class
for that proxy. If you have Soap over HTTP, then you get a proxy class that
derives from the SOAP/HTTP base class:

public class MyService :
System.Web.Services.Protocols.SoapHttpClientProtocol { ... }

If the protocol is HTTP/GET then
public class MyService :
System.Web.Services.Protocols.HttpGetClientProtocol { ... }

System.Web.Services.Protocols.HttpPostClientProtocol is another option.

In all of the above cases (SOAP, GET, POST), the base class derives from
System.Web.Services.Protocols.HttpWebClientProtocol , which supports the
attachment of a CookieContainer.

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebServicesProtocolsHttpWebClientProtocolClassCookieContainerTopic.asp

All of this is in the documentation. Do you have MSDN Library installed?
If not that, then you can view the doc online (as per the above links).

-D

"Vincent Finn" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Vincent Finn
On Wed, 8 Sep 2004 08:48:50 -0400, "Dino Chiesa [Microsoft]"
<Click here to reveal e-mail address> wrote:

[Original message clipped]

Ah
I am seeing a light at the end of the tunnel

[Original message clipped]

I have the MSDN and I had read all the pages you mentioned before
posting the question.

The bit that wasn't clear to me was where I got the 'ServerUsage' and
'Session' objects in the client.

Your comment at the top has cleared it up.
The 'ServerUsage' object is the web reference to my web service
and the 'Session' is not relevant (or required) in my case, I can use
a member variable

It has taken a while but it finally makes sense!

    Thanks for your patience :)
        Vin
Reply to this message...
 
 
System.DateTime
System.Net.CookieContainer
System.Web.Services.Protocols.HttpGetClientProtocol
System.Web.Services.Protocols.HttpPostClientProtocol
System.Web.Services.Protocols.HttpWebClientProtocol
System.Web.Services.Protocols.SoapHttpClientProtocol




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com