ASP.NET and IIS6: Capturing All Application Errors

Our legacy ASP 3.0 web applications for teams were able to take advantage of the global error file by setting up their own error file on the "IIS Custom Error" tab. I can not find a similar solution for ASP.NET applications.

Does anyone know if there is a way to have a centralized "Error.aspx" page (for example) that will catch errors for the entire application pool? The goal is to not add custom code to every Global Error Handler application ....

Any guidance is appreciated!

+3
source share
5 answers

<customErrors defaultRedirect="[url]"></customErrors> web.config machine.config . , .

, machine.config .

+1

Application_Error global.asax.cs.

, - :

Exception myError = Server.GetLastError();
Exception baseException = myError.GetBaseException();
+1

ELMAH , , . , -:

http://code.google.com/p/elmah/

Then you can also include <customErrors> in your web.config to make sure they were redirected to the error page. ELMAH will make sure you are notified of everything.

+1
source

You also commit an error using the Application_OnError event in the Global.asax file. Then you can do as Ben R. said. Capture the error using the Server.GetLastError () procedure.

0
source

You can also create a custom module called "ErrorHandlingModule" that will go into the HttpModule.

public class ErrorHandlingModule : IHttpModule
{
    public void Init(HttpApplication application)
    {
        application.Error += new System.EventHandler(OnError);
    }

    public void OnError(object obj, EventArgs args)
    {
        Exception ex = HttpContext.Current.Server.GetLastError();
        //Log your error here or pick a funny message to display
        HttpContext.Current.Server.ClearError();
        HttpContext.Current.Response.Redirect("/Error.aspx", false);
    }
}

It will look something like this.

0
source

Source: https://habr.com/ru/post/1698507/


All Articles