Indicates whether session state is enabled for an XML Web service method.
Assembly: System.Web.Services (in System.Web.Services.dll)
In order to store session state in the ASP.NET HttpSessionState object, the XML Web service must inherit from WebService and a WebMethodAttribute applied to the XML Web service method, setting the property to true. If session state is not needed for an XML Web service method, then disabling it may improve performance.
An XML Web service client is uniquely identified by an HTTP cookie returned by an XML Web service. In order for an XML Web service to maintain session state for a client, the client must persist the cookie. Clients can receive the HTTP cookie by creating a new instance of CookieContainer and assigning that to the CookieContainer property of the proxy class before calling the XML Web service method. If you need to maintain session state beyond when the proxy class instance goes out of scope, the client must persist the HTTP cookie between calls to the XML Web service. For instance, a Web Forms client can persist the HTTP cookie by saving the CookieContainer in its own session state. Because not all XML Web services use session state and thus clients are not always required to use the CookieContainer property of a client proxy, the documentation for the XML Web service should state whether session state is used.
The example below uses session state to determine how many times a particular session accesses the XML Web service method SessionHitCounter.
The following code example is a Web Forms client of an XML Web service that uses session state. The client persists the HTTP cookie that uniquely identifies the session by storing it in the client's session state.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.