共用方式為


Control.Context 屬性

定義

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。

protected:
 virtual property System::Web::HttpContext ^ Context { System::Web::HttpContext ^ get(); };
protected public:
 virtual property System::Web::HttpContext ^ Context { System::Web::HttpContext ^ get(); };
[System.ComponentModel.Browsable(false)]
protected virtual System.Web.HttpContext Context { get; }
[System.ComponentModel.Browsable(false)]
protected internal virtual System.Web.HttpContext Context { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Context : System.Web.HttpContext
Protected Overridable ReadOnly Property Context As HttpContext
Protected Friend Overridable ReadOnly Property Context As HttpContext

屬性值

HttpContext

與目前要求相關之指定的 HttpContext 物件。

屬性

範例

protected override bool OnBubbleEvent(object sender, EventArgs e)
{

   // Use the Context property to write text to the TraceContext object
   // associated with the current request.
   Context.Trace.Write("The ParentControl's OnBubbleEvent method is called.");
   Context.Trace.Write("The Source of event is: " + sender.ToString());

   return true;
}
<System.Security.Permissions.PermissionSetAttribute( _
    System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Function OnBubbleEvent(ByVal sender As Object, ByVal e As EventArgs) As Boolean

    ' Use the Context property to write text to the TraceContext object
    ' associated with the current request.         
    Context.Trace.Write("The ParentControl's OnBubbleEvent method is called.")
    Context.Trace.Write("The Source of event is: " + sender.ToString())

    Return True
End Function 'OnBubbleEvent

備註

這個屬性可讓您存取 HttpContext 目前 Web 要求的 物件。 物件提供屬性,這些屬性會存取 ApplicationSessionResponse Request 和其他物件,其中包含目前 HTTP 要求的相關資訊。 它也提供方法,可讓您取得設定資訊,並設定或清除要求的錯誤。

適用於

另請參閱