Use Objects and Intrinsics
This sample illustrates how to access ASP.NET intrinsics such as the
Session and
Application objects. It also shows how to turn off
Session on a per-[WebMethod] basis.
The first method in the sample .asmx file, UpdateHitCounter, accesses the Session and adds 1 to the "HitCounter" value. It then returns this value as a String. The second method, UpdateAppCounter does the same thing, but with the Application. Notice the following:
<WebMethod(EnableSession:=true)>
VB
Session state for XML Web services is disabled by default, and you have to use a special attribute property to enable Sessions. However, Sessions aren't needed for this object, since it only uses the Application object.
When the client proxy is accessed, it contains a cookie collection. This collection is used to accept and return the APSESSIONID cookie that ASP.NET uses to track Sessions. This is what allows this client to receive varying answers to the Session hit method.
Copyright 2001 Microsoft Corporation. All rights reserved.