WebService.Context Özellik

Tanım

HttpContext Web isteklerini işlemek için HTTP sunucusu tarafından kullanılan tüm HTTP'ye özgü bağlamı kapsülleyen geçerli isteğin ASP.NET alır.

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

Özellik Değeri

HttpContext

Geçerli isteğin ASP.NETHttpContext.

Öznitelikler

Özel durumlar

Context, null değeridir.

Örnekler

Aşağıdaki Örnek, sunucudaki isteğin zamanını almak için özelliğini kullanır Context .

<%@ WebService Language="C#" Class="Util" %>
 
 using System;
 using System.Web.Services;
 
 public class Util: WebService {
   [ WebMethod(Description="Returns the time as stored on the Server",
   EnableSession=false)]
   public string Time() {
      return Context.Timestamp.TimeOfDay.ToString();
   }
 }
<%@ WebService Language="VB" Class="Util" %>
 
Imports System
Imports System.Web.Services

Public Class Util
    Inherits WebService
    
    <WebMethod(Description := "Returns the time as stored on the Server", _
        EnableSession := False)> _
    Public Function Time() As String
        
        Return Context.Timestamp.TimeOfDay.ToString()
    End Function
End Class

Açıklamalar

veya SoapDocumentMethodAttribute özniteliğine OneWay sahip ve özelliği olarak ayarlanmış truexml web hizmeti yöntemleriSoapRpcMethodAttribute, statik Current özelliği kullanarak bunlara HttpContext erişemeyebilir. öğesine erişmek HttpContextiçin, öğesinden WebService XML Web hizmeti yöntemini uygulayan sınıfını türetip özelliğine erişin Context .

Şunlara uygulanır

Ayrıca bkz.