Application level Error handler

An application level error-handler handles all exceptions not handled in the application. The application leven event-handler is created in the Global.asax. Be aware that the customredirect is disabled in the web.config. The error handler is doing a redirect to the error page, the custom redirect in de web.config otherwise is mixing things up.

Example:

 
    void Application_Error(object sender, EventArgs e) 
    { 
      Exception exc = Server.GetLastError (); 
      string mijnerrror = exc.Message; 
      Response.Write("Er is een error gevangen"); 
      Response.Write(exc.Message + "\n"); 
      Response.Write("Return to the " + "Default Page\n"); 
      Server.Transfer("~/Error.aspx"); }

 

When the error is catched in this method in the Global.asax the request is redirected to the error page. The first thing that must be done is to remove the error from the context.

 
protected void Page_Load(object sender, EventArgs e) 
{ 
    if(Server.GetLastError() != null) 
    { 
      ex = (HttpException)Server.GetLastError(); 
      this.txtError.Text = ex.InnerException.InnerException.ToString () ; 
    } 
}

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!