Gets the application object for the current HTTP request.
Assembly: System.Web.Services (in System.Web.Services.dll)
<[%$TOPIC/a9a78ahz_en-us_VS_110_1_0_0_0_0%](False)> _
Public ReadOnly Property Application As [%$TOPIC/a9a78ahz_en-us_VS_110_1_0_0_0_1%]
[[%$TOPIC/a9a78ahz_en-us_VS_110_1_0_1_0_0%](false)]
public [%$TOPIC/a9a78ahz_en-us_VS_110_1_0_1_0_1%] Application { get; }
[[%$TOPIC/a9a78ahz_en-us_VS_110_1_0_2_0_0%](false)]
public:
property [%$TOPIC/a9a78ahz_en-us_VS_110_1_0_2_0_1%]^ Application {
[%$TOPIC/a9a78ahz_en-us_VS_110_1_0_2_0_2%]^ get ();
}
[<[%$TOPIC/a9a78ahz_en-us_VS_110_1_0_3_0_0%](false)>]
member Application : [%$TOPIC/a9a78ahz_en-us_VS_110_1_0_3_0_1%] with get
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).
The example below demonstrates a hit counter, incrementing the count every time a browser calls the XML Web service method.
<%@ 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
<%@ 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"]);
}
}
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.