
Error | 295
HttpContext
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Cache property is to access the cache at points during request processing when
the Cache property of the Page object is not available, such as before the Page
object is instantiated.
Current
HttpContext = HttpContext.Current
Retrieves the current HttpContext instance.
Parameter
HttpContext
The current context.
Example
This example uses the IsDebuggingEnabled property, described later in this
chapter, to show whether debugging is enabled:
Sub Page_Load( )
Message.Text = HttpContext.Current.IsDebuggingEnabled.ToString( )
End Sub
Notes
Current is a shared (static) property, indicating that you can access it without
creating an instance of the
HttpContext class.
Error
Exception = Context.Error
Returns the first error, if any, associated with the current request.
Parameter
Exception
An Exception variable to receive the value of the property.
Example
The example checks to see if the Error property on the current context object is
null (
Nothing in VB.NET). If it is not null, it displays the error; otherwise, it
displays a message indicating there is no error.
Sub Page_Load( )
If Not HttpContext.Current.Error Is Nothing then
Message.Text = HttpContext.Current.Error.ToString( )
Else
Message.Text = "No error detected"
End If
End Sub