The controller for path ‘/favicon.ico’ was not found or does not implement IController

I was working on an ASP.NET MVC project today and ran across some favicon.ico errors while troubleshooting another issue. When reviewing my event logs, I kept seeing the following error.

The controller for path '/favicon.ico' was not found or does not implement IController.

Thankfully, this error is easy to address by adding a route constraint to the RegisterRoutes() method in your application’s Global class. This constraint ignores all requests for favicon.ico in the application root directory and all sub-directories.

[sourcecode language=”csharp”]

routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

[/sourcecode]

As Phil Haack explains more thoroughly in this post, the problem occurs because browsers look for the favicon.ico file and MVC routing does not support this request. But adding the ignore route constraint resolves the issue quickly and easily.

Comments are closed.

Sign in
classic
Forgot password?
×
Sign up

(*) Required fields

I agree with OptimaSales Terms & Privacy Policy

×