WebService.Application Property
Gets the application object for the current HTTP request.
[Visual Basic] Public ReadOnly Property Application As HttpApplicationState [C#] public HttpApplicationState Application {get;} [C++] public: __property HttpApplicationState* get_Application(); [JScript] public function get Application() : HttpApplicationState;
Property Value
An HttpApplicationState object.
Remarks
XML Web services can use both application state and session state. Application state is maintained across all sessions accessing an XML Web service regardless of whether session state is turned off for a method(by using the EnableSession property of the WebMethodAttribute).
Example
[Visual Basic, C#] The example below demonstrates a hit counter, incrementing the count every time a browser calls the XML Web service method.
[Visual Basic] <%@ WebService Language="VB" Class="Util"%> Imports System.Web.Services Public Class Util Inherits WebService <WebMethod(Description := "Application Hit Counter", _ EnableSession := False)> _ Public Function HitCounter() As Integer If Application("HitCounter") Is Nothing Then Application("HitCounter") = 1 Else Application("HitCounter") = CInt(Application("HitCounter")) + 1 End If Return CInt(Application("HitCounter")) End Function End Class [C#] <%@ WebService Language="C#" Class="Util"%> using System.Web.Services; public class Util: WebService { [ WebMethod(Description="Application Hit Counter",EnableSession=false)] public int HitCounter() { if (Application["HitCounter"] == null) { Application["HitCounter"] = 1; } else { Application["HitCounter"] = ((int) Application["HitCounter"]) + 1; } return ((int) Application["HitCounter"]); } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
WebService Class | WebService Members | System.Web.Services Namespace | HttpApplicationState