Asp.net mvc 2 customErrors iis 7.5 not working

My site runs on asp.net mvc2 and I use elmah to catch errors, not handleerror attibute

if I go to a non-existing page, for example 'HTTP: // local: 8095 / Home / City / 1 / MTL / co' I get an 404 IIS page error

in web.config I configured my custom errors

 

I even tried to set the code in global.asax application_error and didn't get there

Why am I getting an IIS 404 error page?

Now that I think about it, I would like to register 404 errors, where could I lure them into asp.net mvc?

thank

+3
source share
1 answer

I know this is an old question, but I decided to answer:

Elmah , : http://code.google.com/p/elmah/wiki/ErrorFiltering

Gloabal.asax.cs :

public static void RegisterRoutes(RouteCollection routes)
{               
    routes.IgnoreRoute("elmah.axd"); //Add this line to the register routes.
}

//ELMAH Filtering
protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
{
    FilterError404(e);
}

protected void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
    FilterError404(e);
}

//Dimiss 404 errors for ELMAH
private void FilterError404(ExceptionFilterEventArgs e)
{
    if (e.Exception.GetBaseException() is HttpException)
    {
        HttpException ex = (HttpException)e.Exception.GetBaseException();

        if (ex.GetHttpCode() == 404)
        {
            e.Dismiss();
        }
    }
}

, , , 404. , , .

: http://joel.net/logging-errors-with-elmah-in-asp.net-mvc-3--part-3--filtering http://ivanz.com/2011/05/08/asp-net-mvc-magical-error-logging-with-elmah/

0

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


All Articles