Name

Error

Synopsis

Exception = Context.Error

Returns the first error, if any, associated with the current request.

Parameters

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

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.