14

I am using a custom ControllerFactory (to use Castle Windsor's IOC to create controllers), and I notice it's getting requests to create a controller for "favicon.ico". I have put a favicon.ico file in my Content folder, but I'm still getting these requests.

How do I resolve this and serve static content without trying to create controllers?

ripper234
  • 222,824
  • 274
  • 634
  • 905
  • 1
    This was happening to me because browsers try to look for the favicon.ico in your root and for some reason asp.net thinks it's a controller, and it filled my logs with the error "favicon.ico controller not found", I don't know if this is what you are talking about. – ryudice Dec 30 '09 at 07:39

1 Answers1

28

Add the following route:

routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 1
    Why not just `routes.IgnoreRoute("favicon.ico")`? – ANeves Apr 17 '12 at 10:12
  • 2
    The suggested IgnoreRoute ignores favicon.ico in any folder, not just the root. I think it comes from Phil Haack's blog (http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx) – Robin Minto Jan 04 '13 at 11:21
  • 1
    Oh, and it should be \. for the . in the regular expression i.e. favicon\.ico – Robin Minto Jan 04 '13 at 11:22