如何在ASP.NET MVC中提供favicon.ico的最终/最佳建议是什么?
我目前正在执行以下操作:
在我的RegisterRoutes方法非常开始处添加一个条目:
routes.IgnoreRoute("favicon.ico");
将favicon.ico放在我的应用程序根目录中(这也将是我的域的根目录)。
我有两个问题:
- 是否没有其他位置可以放置favicon.ico而不是在应用程序的根目录中。它与
Content
和Controllers
位于同一级别,这很糟糕。 这个
IgnoreRoute("favicon.ico")
语句是否足够-或者我还应该像Phil Haack的博客文章中讨论的那样做以下操作? 我不知道是否曾经在除根目录之外的任何目录中看到过对favicon.ico的请求 - 这将使此操作不必要(但了解如何执行此操作很好)。routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"});
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*[/\\])?favicon\.((ico)|(png))(/.*)?" });
- BrainSlugs83routes.MapRoute("IgnoreFavicon", "{*favicon}", new { favicon = @"(.*[/\\])?favicon\.((ico)|(png))(/.*)?" });
- Rentering.comroutes.MapRoute("Ingore", "{*favicon}", new { }, new { favicon = @"(.*[/\\])?favicon\.((ico)|(png))(/.*)?" });
注意new {}
。 - Rentering.com