Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 Error Event
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
HttpApplication..::.Error Event

Updated: November 2007

Occurs when an unhandled exception is thrown.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

Visual Basic (Declaration)
Public Event Error As EventHandler
Visual Basic (Usage)
Dim instance As HttpApplication
Dim handler As EventHandler

AddHandler instance.Error, handler
C#
public event EventHandler Error
Visual C++
public:
 event EventHandler^ Error {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
J#
/** @event */
public void add_Error (EventHandler value)
/** @event */
public void remove_Error (EventHandler value)
JScript
JScript does not support events.

The exception that raises the Error event can be accessed by a call to the GetLastError method. If your application generates custom error output, suppress the default error message that is generated by ASP.NET by a call to the ClearError method.

Note:

If your Web application contains XML Web services, you cannot use the Error event for global exception handling of those services. The HTTP handler for XML Web services consumes any exception that occurs in an XML Web service and converts it to a SOAP fault before the Error being called. To handle XML Web service exceptions, build a SOAP extension to process Web service exceptions in a custom global exception handler. For more information, see Handling and Throwing Exceptions in XML Web Services.

For more information about how to handle events, see Consuming Events.

TopicLocation
How to: Display Safe Error MessagesBuilding ASP .NET Web Applications
How to: Display Safe Error MessagesBuilding ASP .NET Web Applications
How to: Display Safe Error MessagesBuilding ASP .NET Web Applications in Visual Studio

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker