Live Chat Icon For mobile
Live Chat Icon

How to display errors using Page_Error event of Page Object

Platform: ASP.NET| Category: Error Handling

VB.NET


Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error
        	Response.Write(Server.GetLastError().ToString)
        	Server.ClearError()
End Sub

C#


//In InitializeComponent 
this.Error += new System.EventHandler (this.Page_Error );

//
private void Page_Error(object sender, System.EventArgs e   ) 
{
	Response.Write(Server.GetLastError().ToString());
	Server.ClearError ();
}

In the Same manner handle the Errors in the Application_Error event in global.asax

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.