• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Implementing a favourite icon (favicon) in ASP.NET

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Implementing a favourite icon (favicon) in ASP.NET

When the thought of adding a favicon, or rather, a favourite icon to your website appears on your todo list, you instantly think it’s a quick, easy 5 minute job. In most scenario’s, it is, however adding a favicon to an asp.net website can be a whole different kettle of fish.

Sure, the principles are the same, you add a basic tag to the header of your page, usually within a master template, and you make sure you have a nice looking 16×16 favicon.ico file located in your web root. Depending on your site configuration though, you might be about to embark on an absolute nightmare of a journey. That is, of course, unless you are reading this handy tip.

If you add the HTML for a favicon and start to test in your favourite web browser (assuming that’s not Internet Explorer 7…), you’ll notice the favicon (should) work flawlessly, and hopefully looks pretty nice too. But, you may find, when you check your favicon in Internet Explorer 7, you’re presented with the default, boring IE icon in your address bar, and no favicon!

After a few hours of Googling and scratching your head, making several tweaks to your code, tweaking your icon, a broken ‘F5′ key, and wondering what the problem is, you’ll probably begin to think it’s just Internet Explorer being funny and deciding not to play nice. In a way, thats true, but there is a way to resolve it.

Your ASP.NET website should have a ‘web.config’ file in your web root, containing various different configuration entries. One particular entry is:

<staticContent>
            <clientCache cacheControlMode="" />
</staticContent>

If ‘cacheControlMode’ is set to ‘DisableCache’, then this could very well be the reason that your favicon does not display correctly in Internet Explorer 7. In our case, this setting was preventing IE7 from placing our favicon into its own cache, and thus did not show correctly.

As a workaround, we have used the following three lines of code to allow IE7 to cache content (and the favicon):


<
staticContent>
            <clientCache cacheControlMode="NoControl" />
</staticContent>

 

 

The end result is a perfectly working favicon in Internet Explorer 7, and all other major browsers.

Unfortunately there does not seem to be much documentation on this from our time spent Googling the issue, so we hope this is of some use to any other web developers experiencing the same issue as us.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ASP.NETCookie发布时间:2022-07-10
下一篇:
ASP.NET结合存储过程写的通用搜索分页程序发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap