4

我应该这样做:

  // 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")" /> 
4

1 回答 1

1

我看不出有任何理由在这里使用所有控制器、动作、路由、actionResult 的东西。第一个选项更简单。

于 2012-05-19T04:10:03.737 回答