
GetAppConfig | 303
HttpContext
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
The example shows how you can use AddError to add an error to the current
request context. The exception is created within a
Try block. In the Finally block,
the ToString method is used to display the error and the ClearError method is
used to clear the error so that the page will display properly.
Sub Page_Load( )
Try
Context.AddError(New Exception("Test"))
Finally
Message.Text = "Context.Error.ToString( ) is " & _
Context.Error.ToString( )
Context.ClearError( )
End Try
End Sub
Notes
Adding an exception by using AddError should not be confused with throwing an
exception. Using AddError only adds the exception to the array returned by the
AllErrors property and does not invoke any of the error handling mechanisms in
the application.
ClearError
Context.ClearError( )
Clears all errors for the current request. Note that even though ClearError is
singular, it clears all errors for the current request.
Parameters
None.
Example
The example checks whether there are any errors and then clears them. Finally, it
reports if it has cleared any errors.
Sub Page_Load( )
If Not Context.AllErrors Is Nothing Then
Context.ClearError( )
Message.Text = "Errors cleared."
Else
Message.Text = "No Errors to clear."
End If
End Sub
GetAppConfig
Object = HttpContext.GetAppConfig(ByVal ...