Edit

Share via


WebService.Application Property

Definition

Gets the application object for the current HTTP request.

[System.ComponentModel.Browsable(false)]
public System.Web.HttpApplicationState Application { get; }

Property Value

An HttpApplicationState object.

Attributes

Examples

The example below demonstrates a hit counter, incrementing the count every time a browser calls the XML Web service method.

<%@ 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"]);
    }   
 }

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).

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also