ASP.NET MVC5 Elmah Error Log / Email Controller for path not found

Yesterday, I configured Elma to send me an email every time an unhandled exception is raised that causes my website to crash.

This morning I woke up and saw 6 letters with the exception of:

"System.Web.HttpException: Controller for path '/ none' not found or does not implement IController.

They were from the Bing bot robot. There were 2 more from Google and Yahoo robots.

I looked through my code and tested all my links on my website and did not find any errors. Nowhere am I trying to switch to the controller "none". The other 2 errors were similar, but point to a couple of other controllers, but they work fine when I test them.

What am I doing wrong and how can I get rid of these errors?

I am concerned that they rank my site lower in search engines.

Update:

Finally, I was able to reproduce the errors. In my browser I typed: "www.mysite.com/abcde". On page 404, an error of my site was shown, which is good. However, Elmah created an email

'Controller for path' / abcde 'not found or does not implement IController

When I typed: "www.mysite.com/Home/abcde", my 404 error page showed. Then Elma sent this letter:

"The open action method" abcde "was not found on the controller" MySite.Controllers.HomeController ".

This leads me to the conclusion that for some reason, web crawler spiders are trying to access URLs on my site that were deleted or never existed.

elmah , URL-, ? , - URL-, .

, , URL- , "/none" "/error_log" ?

+4
2

.

:

  • , IExceptionFilter. , . .

    public class ElmahHandledErrorLoggerFilter : IExceptionFilter
    {
        public void OnException(ExceptionContext context)
        {
            if (context.ExceptionHandled)
                ErrorSignal.FromCurrentContext().Raise(context.Exception);
        }
    }
    
  • ElmahHandledErrorLoggerFilter GlobalFilterCollection FilterConfig. . TransactionFilter.

    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new TransactionFilter());
        filters.Add(new ElmahHandledErrorLoggerFilter());
    }
    
  • Globals.asax.cs , 404 .

        protected void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
        {
            FilterError404(e);
        }
    
        protected void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
        {
            FilterError404(e);
        }
    
        // Dismiss 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 , / .

Xenu .

, Elmah .

+1

, , - "none" - -, script - ( click, nav). , , , , , script.

( , HTMLAgilityPack, ), , , .

+1

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


All Articles