Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6626489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:53:54+00:00 2026-05-25T21:53:54+00:00

I have a .net application that uses customerrors web.config module to display meaningful messages

  • 0

I have a .net application that uses customerrors web.config module to display meaningful messages for errors. It works without any issues for 500 errors/exceptions caused by non-ajax and ajax components (updatepanel). However, in a scenario where updatepanel’s asynchronous request times out, there is no error raised at all. I was able to see the timeout in firebug and come up with a solution that would at least display the error message as an alert and then redirect the user to the 500 error page using javascript but it’s not quite doing what the rest of the application does in case of an unhandled errors like these. I basically just want everything to go through “LogEvent” mechanism so based on the severity of the error, it does the necessary work.

Here are my questions:

  1. This 500 error page doesn’t have anything in the
    Server.GetLastError() for these timeout scenarios. Is this an
    expected behaviour?
  2. Can it be changed so I do have access to these timeouts in
    Server.GetLastError() OR maybe just run this error through “LogEvent” mechanism?
  3. Is there a better/more graceful way to handle this issue?

Below is my code to give you an idea, not exactly what I have in my application but pretty close.

Web.Config

<customErrors mode="On" defaultRedirect="~/Errors/ErrorUnknown.aspx" redirectMode="ResponseRewrite">
  <error statusCode="500" redirect="~/Errors/Error500.aspx" />
</customErrors>

Error500.aspx.vb

Dim lastException As Exception = Server.GetLastError()

If lastException IsNot Nothing Then LogEvent(LogLevel.Error, "UnHandled Error From 500 Error Page.", lastException)

LblErrorMessage.Text = "Unknown error occured when processing your request."

Session.Abandon()

Page With UpdatePanel ASPX

<asp:ScriptManager ID="AppScriptManager" AsyncPostBackTimeout="3" runat="server" AllowCustomErrorsRedirect="True" OnAsyncPostBackError="AppAsyncPostBackError" AsyncPostBackErrorMessage="There was an error processing your request!" />

Javascript on the Page with UpdatePanel ASPX

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
    });
    function endRequestHandler(sender, args) {
        if (args.get_error() != undefined) {
            var errorMessage = "There was an error processing your request!";
            errorMessage += '\nError message: ' + args.get_error().message;
            args.set_errorHandled(true);
            alert(errorMessage);
            window.location.replace('Errors/Error500.aspx');
        }
    }        
</script>

Page With UpdatePanel ASPX.VB

Public Sub AppAsyncPostBackError(sender As Object, e As System.Web.UI.AsyncPostBackErrorEventArgs) Handles AppScriptManager.AsyncPostBackError

    LogEvent(LogLevel.Fatal, "Asyncpostback error from update panel.", e.Exception)

End Sub

Function to log events using NLog

Private Sub LogEvent(level As LogLevel, logMessage As String, exception As Exception, ParamArray args() As Object)

    Try

        Dim appLogger As Logger = LogManager.GetCurrentClassLogger()

        If exception IsNot Nothing Then

            '# If it's an exception store it in a seperate file as fatal exception
            appLogger.LogException(level, String.Format(logMessage, args), exception)

            '# send an email
            SendErrorEmail(String.Format(logMessage, args), exception)

            '# Throw Exception as this was fatal
            If level = LogLevel.Fatal Then Throw

        Else

            '# Log the message
            appLogger.Log(level, logMessage, args)

        End If

    Catch ex As Exception

    End Try

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:53:55+00:00Added an answer on May 25, 2026 at 9:53 pm

    Yes, the server error 500 is something to do with the web server.

    Read this knowledge base from Microsoft:
    “How Web site administrators can troubleshoot an “HTTP 500 – Internal Server Error” error message on IIS 4.0 or on IIS 5.0“

    And please don’t mess up with HTTP error messages. Error 500 is usually known when error happens at web server, not the application. Therefore, giving error 500 for your redirects is not recommended, it will confuse web administrator and also developers.

    This is the reason: “Description of Hypertext Transport Protocol error messages”

    Your best bet to handle this issue is having logging mechanism such as the one in Log4Net (log for .NET), or use logging in Microsoft’s Enterprise Library 5.0. Before that, you can use custom error/exception pages but don’t handle error 500.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# web forms ASP.NET 4.0 web application that uses Routing for
We have an ASP.NET application that uses the Infragistics WebSchedule control to display appointments
I have an ASP.NET web application that uses jQuery on client side. On one
We have developed a .NET web application that uses SQL Server as a backend.
I have a .NET 2.0 application that uses WSE 3.0 to make web service
I have a ASP.NET web application that uses Themes. Inside the theme directory are
I have a .NET 4.0 web application that uses a .NET 2.0 assembly. I've
I have just re-implemented an ASP.NET web application that uses NHibernate to use a
I have an asp.net mvc application that uses web service. I have various controllers
I have an older ASP.NET MVC application that uses classic web forms views. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.