Skip to main content
.NET Framework 4.6.2+
  • The page you are viewing does not exist in the .NET 8.0+ platform documentation. This link will take you to the parent topic of the current section.

ErrorHandling.CustomSendErrorNotification Event

Occurs before determining whether it is possible to send the error alert to the application administrator.

Namespace: DevExpress.ExpressApp.Web

Assembly: DevExpress.ExpressApp.Web.v24.2.dll

NuGet Package: DevExpress.ExpressApp.Web

Declaration

public static event EventHandler<CustomSendErrorNotificationEventArgs> CustomSendErrorNotification

Event Data

The CustomSendErrorNotification event's data class is CustomSendErrorNotificationEventArgs. The following properties provide information specific to this event:

Property Description
ErrorDetails Gets the complete error description, including the request details, loaded assemblies, last trace entries, etc.
ErrorId Gets the identifier of the error that occurred.
ErrorText Gets the text of the error message.
Exception Gets the exception that occurred.
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
MessageBody Gets the body of the error notification message.
MessageSubject Gets the subject of the error notification message.

Remarks

The CustomSendErrorNotification event is raised as a result of invoking the ErrorHandling.SendAlertToAdmin method. By default, the e-mail message with error details is sent to a recipient specified in the Web.config file when an error occurs (see Error Handling in ASP.NET Web Forms Applications). You can customize this behavior by subscribing to this event in the ASP.NET Web Forms application’s Application_Start method. For instance, you can implement your own notification mechanism (via instant messaging, etc.), or cancel sending notifications in specific cases. The handler’s Handled parameter cancels sending the default notification. Do not forget to unsubscribe from the CustomSendErrorNotification in the Application_End method. The following snippet illustrates how to ignore exceptions from the Security System (unsuccessful login attempts, etc).

protected void Application_Start(Object sender, EventArgs e) {
    ErrorHandling.CustomSendErrorNotification += ErrorHandling_CustomSendErrorNotification;
    // ...
}
private void ErrorHandling_CustomSendErrorNotification(
    object sender, CustomSendErrorNotificationEventArgs e) {
    if (e.Exception.Source.StartsWith("DevExpress.ExpressApp.Security.")) e.Handled = true;
}
protected void Application_End(Object sender, EventArgs e) {
    // ...
    ErrorHandling.CustomSendErrorNotification -= ErrorHandling_CustomSendErrorNotification;
}

If you want to use e-mail notifications supplied by default, but need to customize their options, handle the ErrorHandling.CustomSendMailMessage event instead of this event.

See Also