我应该这样做:
// Best practice to avoid MVC handling the favicon request
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
或者这个:
[OutputCache(Duration = 3600, Location = OutputCacheLocation.Client)]
public ActionResult Favicon() {
var icon = Server.MapPath("~/content/ico/favicon.ico");
return File(icon, "image/x-icon");
}
and
<link rel="shortcut icon"
type="image/x-icon"
href="@Url.Action("Favicon", "SomeController")" />
答案 0 :(得分:1)
我没有看到任何理由在这里使用所有控制器,动作,路线,actionResult事情。第一种选择更简单。