WebService.Application Propriedade

Definição

Obtém o objeto do aplicativo para a solicitação HTTP atual.Gets the application object for the current HTTP request.

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

Valor da propriedade

HttpApplicationState

Um objeto HttpApplicationState.An HttpApplicationState object.

Atributos

Exemplos

O exemplo a seguir demonstra um contador de ocorrências, incrementando a contagem toda vez que um navegador chama o método de serviço Web XML.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"]);
    }   
 }
<%@ 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

Comentários

Os serviços Web XML podem usar o estado do aplicativo e o estado da sessão.XML Web services can use both application state and session state. O estado do aplicativo é mantido em todas as sessões que acessam um serviço Web XML, independentemente de o estado da sessão ser desativado para um método (usando a EnableSession Propriedade do WebMethodAttribute ).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).

Aplica-se a

Confira também