.Net Interview Question: How can we maintain State in Web Services?

Web services as such do not have any mechanism by which they can maintain state. Web services can access ASP.NET intrinsic objects like Session, application and so on if they inherit from Web Service base class.

<%@ Webservice class="TestWebServiceClass" %>
Imports System.Web.Services
Public class TestWebServiceClass
Inherits WebService
<WebMethod> Public Sub SetSession(value As String)
session("Val") = Value
End Sub
end class