Control.Context 屬性

定義

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

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 物件。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. 物件所提供的屬性可存取 ApplicationSessionRequest Response 和其他物件,其中包含目前 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.

適用於

另請參閱