I get an error:
\"The controller for path \'/favicon.ico\' was not found or does not implement IController\"
Then I thought: how
You can also specify the ignore route with constraints
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
The top answers are correct.
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
But for newer versions of MVC you must add this at the top of the RegisterRoutes method in RouteConfig.cs (so somewhere before routes.MapRoute(..) is called).
Add this to you global.asax:
routes.IgnoreRoute("favicon.ico");
Interesting as it sounds I got this error only if I had checked the "Enable Just My Code" option under tools->options->debugging
, and as soon as I unchecked it I am no longer getting this error.
Note however that it appears that the error is still being thrown behind the scenes but being caught immediately internally, so the best solution is to code in the global.asax to ignore it as the other answers suggest.
You are probably getting this with the VS web server. Right?
You wouldn't get this with IIS since IIS (by default) handles requests for images (.ico, .jpg, .gif, et cetera) and therefore they don't make it to your app.