System.Web.Services.WebMethodAttribute.EnableSession Property

Indicates whether session state is enabled for an XML Web service method.

Syntax

public bool EnableSession { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

In order to store session state in the ASP.NET System.Web.SessionState.HttpSessionState object, the XML Web service must inherit from System.Web.Services.WebService and a System.Web.Services.WebMethodAttribute applied to the XML Web service method, setting the WebMethodAttribute.EnableSession 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 System.Net.CookieContainer and assigning that to the System.Web.Services.Protocols.HttpWebClientProtocol.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 System.Net.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 System.Web.Services.Protocols.HttpWebClientProtocol.CookieContainer property of a client proxy, the documentation for the XML Web service should state whether session state is used.

Requirements

Namespace: System.Web.Services
Assembly: System.Web.Services (in System.Web.Services.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0