WebService.Application 속성

정의

현재 HTTP 요청에 대한 애플리케이션 개체를 가져옵니다.

public:
 property System::Web::HttpApplicationState ^ Application { System::Web::HttpApplicationState ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.HttpApplicationState Application { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Application : System.Web.HttpApplicationState
Public ReadOnly Property Application As HttpApplicationState

속성 값

HttpApplicationState

HttpApplicationState 개체입니다.

특성

예제

아래 예제에서는 XML 웹 서비스 메서드를 호출 하는 브라우저 때마다 개수가 증가 적중된 카운터를 보여 줍니다.

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

설명

XML Web services 애플리케이션 상태와 세션 상태를 모두 사용할 수 있습니다. 메서드에 대 한 세션 상태 해제 되어 있는지 여부에 관계 없이 XML 웹 서비스에 액세스 하는 모든 세션에서 애플리케이션 상태가 유지 됩니다 (사용 하 여 합니다 EnableSession 의 속성을 WebMethodAttribute).

적용 대상

추가 정보