Coder Social home page Coder Social logo

Comments (6)

afastrunner avatar afastrunner commented on June 9, 2024

These are the errors that YOUR site has raised that were caught by ElmahCore. If your site doesn't have a favicon.ico browsers automatically try to load one when they go to a domain. which will raise a 404 error.

Do you really want to log all 404 errors?
I think a lot of us filter out 400 errors something like:

 public class CmsErrorLogFilter : IErrorFilter
    {
        public void OnErrorModuleFiltering(object sender, ExceptionFilterEventArgs args)
        {
            if (args.Exception.GetBaseException() is FileNotFoundException)
                args.Dismiss();

            if (args.Context is HttpContext httpContext)
            {
                if (httpContext.Response.StatusCode == 404)
                    args.Dismiss();

                if (httpContext.Response.StatusCode == 400)
                    args.Dismiss();
            }
        }
    }

from elmahcore.

tnfoundry avatar tnfoundry commented on June 9, 2024

@afastrunner - thank you, I did not say ElmahCore was the issue, but trying to understand. I don't maintain the source code for the route .../elmah/errors. The is a generated route from the ASPNET Core config. It appears that the /elmah/errors route is attempting to reference favicon.ico from its generated Elmah log error user interface that is shown the original posting. Can you explain how or where the ElmahCore admin interface is generated from?

from elmahcore.

afastrunner avatar afastrunner commented on June 9, 2024

when your browser goes to localhost:7065/elmah/errors the browser says to it's self "lets see if this domain localhost has a favicon.ico I can display in the browser tab and requests it from /favicon.ico" the /favicon.ico request starts with / so it's made to the root application localhost:7065/favicon.ico which is your application, the static file middleware there says "nope I don't have favicon.ico and raises a 404 exception" elmah middleware sees the 404 exception and logs it's in the interface your seeing.
Adding a favicon.ico in the elmah/errors location wouldn't prevent this.
So it goes back to to what you want to do, ether have 404 error messages logged or not. OR add a favicon.ico to the /wwwroot folder in your application to prevent this one 404 error OR I guess if you really wanted to you could add a middleware that look for requests to /favicon.ico and returns 200 (but that would be odd)

from elmahcore.

tnfoundry avatar tnfoundry commented on June 9, 2024

@afastrunner - thank you for your time to explain. And that it my understanding of what is going on too, but the confusion comes from the fact that dropping a favicon on the root of localhost:7065 had no affect when I tried before submitting this issue to GitHub. Plus I never realized that a browser always tries request a favicon.ico even if there isn't page containing meta data link/referencing one. Surprised I've never ran into that.

You mention a wwwroot folder, but my root are just libraries and does not have wwwroot. I guess I give that a try

from elmahcore.

afastrunner avatar afastrunner commented on June 9, 2024

Yeah if it's WebAPI you likely don't have Static files Middleware enabled so putting favicon.ico in your root doesn't serve anything. If it was a MVC/Razor you would have a wwwroot folder and static files middleware serving files from that folder.
Best bet is just ignore that error or specifically filter it out in IErrorFilter

from elmahcore.

tnfoundry avatar tnfoundry commented on June 9, 2024

Many thanks for taking the time to help assist with this. Much appreciated!

from elmahcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.