Control.Context 屬性

定義

取得與目前 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

備註

這個屬性可讓您存取目前 Web 要求的 HttpContext 物件。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.

適用於

另請參閱