Obtiene la instancia de
HttpSessionState para la solicitud actual.
Espacio de nombres: System.Web.Services
Ensamblado: System.Web.Services (en system.web.services.dll)
Visual Basic (Declaración)
Public ReadOnly Property Session As HttpSessionState
Dim instance As WebService
Dim value As HttpSessionState
value = instance.Session
public HttpSessionState Session { get; }
public:
property HttpSessionState^ Session {
HttpSessionState^ get ();
}
/** @property */
public HttpSessionState get_Session ()
public function get Session () : HttpSessionState
Valor de propiedad
Objeto HttpSessionState que representa el objeto de estado de sesión de ASP.NET para la sesión actual.
En el siguiente ejemplo se usa el estado de sesión para determinar cuántas veces una sesión determinada tiene acceso al método de servicios Web XML SessionHitCounter. En este ejemplo, la propiedad EnableSession de WebMethodAttribute se establece en true para obtener acceso al estado de sesión.
<%@ WebService Language="VB" Class="Util" %>
Imports System.Web.Services
Public Class Util
Inherits WebService
<WebMethod(Description := "Per session Hit Counter", _
EnableSession := 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(Description="Per session Hit Counter",EnableSession=true)]
public int SessionHitCounter() {
if (Session["HitCounter"] == null) {
Session["HitCounter"] = 1;
}
else {
Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
}
return ((int) Session["HitCounter"]);
}
}
Windows 98, Windows 2000 Service Pack 4, Windows Millennium, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0