我应该这样做吗:
// 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")" />
最佳答案
我看不出有任何理由在这里使用所有 Controller 、 Action 、路由、actionResult 东西。第一个选项更简单。
关于asp.net-mvc - 我应该让 MVC 处理我的网站图标请求吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10662199/