Control.Context Control.Context Control.Context Control.Context Property

定義

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。Gets the HttpContext object associated with the server control for the current Web request.

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

屬性值

與目前要求相關之指定的 HttpContext 物件。The specified HttpContext object associated with the current request.

範例

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 要求的物件。This property gives you access to the HttpContext object for the current Web request. 物件提供屬性,存取ApplicationSessionRequestResponse和其他物件,包含目前 HTTP 要求的相關資訊。The object provides properties that access the Application, Session, Request, Response and other objects that contain information about the current HTTP request. 它也提供方法,可讓您取得組態資訊,然後設定或清除要求的錯誤。It also provides methods that allow you to obtain configuration information and set or clear errors for the request.

適用於

另請參閱