Freigeben über


WebMethodAttribute-Konstruktor (Boolean)

Initialisiert eine neue Instanz der WebMethodAttribute-Klasse.

Namespace: System.Web.Services
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Sub New ( _
    enableSession As Boolean _
)
'Usage
Dim enableSession As Boolean

Dim instance As New WebMethodAttribute(enableSession)
public WebMethodAttribute (
    bool enableSession
)
public:
WebMethodAttribute (
    bool enableSession
)
public WebMethodAttribute (
    boolean enableSession
)
public function WebMethodAttribute (
    enableSession : boolean
)

Parameter

  • enableSession
    Initialisiert die Aktivierung des Sitzungszustands für die XML-Webdienstmethode.

Beispiel

<%@ WebService Language="VB" Class="Util" %>
 
Imports System.Web.Services

Public Class Util
    Inherits WebService
    
    <WebMethod(True)> _
    Public Function SessionHitCounter() As Integer
        
        If Session("HitCounter") Is Nothing Then
            Session("HitCounter") = 1
        Else
            Session("HitCounter") = CInt(Session("HitCounter")) + 1
        End If
        Return CInt(Session("HitCounter"))
    End Function
End Class
<%@ WebService Language="C#" Class="Util" %>
 
 using System.Web.Services;
 
 public class Util: WebService {
   [ WebMethod(true)]
    public int SessionHitCounter() {
       if (Session["HitCounter"] == null) {
          Session["HitCounter"] = 1;
       }
       else {
          Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
          }
       return ((int) Session["HitCounter"]);
    }   
 }

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

WebMethodAttribute-Klasse
WebMethodAttribute-Member
System.Web.Services-Namespace