加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 我应该让MVC处理我的favicon请求吗?

发布时间:2020-12-16 09:36:53 所属栏目:asp.Net 来源:网络整理
导读:我应该这样做: // Best practice to avoid MVC handling the favicon request routes.IgnoreRoute("{*favicon}",new { favicon = @"(.*/)?favicon.ico(/.*)?" }); 或这个: [OutputCache(Duration = 3600,Location = OutputCacheLocation.Client)] public A
我应该这样做:

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

解决方法

我没有看到任何理由在这里使用所有控制器,动作,路线,actionResult的东西.第一种选择更简单.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读