mvc: does the favicon.ico also look for a controller?

前端 未结 5 1955
灰色年华
灰色年华 2020-12-05 09:34

I get an error:

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

Then I thought: how

5条回答
  •  猫巷女王i
    2020-12-05 09:47

    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).

提交回复
热议问题