网站图标未显示
我的 ASP.NET 项目中有一个图标没有显示。我有一个位于 ~/MasterPages/MasterPage.master 的母版页,其中包含图标。我的标记如下:
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
<link rel="icon" href="/favicon.ico" type="image/x-icon"/>
图标位于项目根目录中。尺寸为 16x16,深度为 32 位。我已经清除了浏览器的缓存,重新启动,但没有任何效果。关于我应该做什么有什么建议吗?
I have a favicon in my ASP.NET project that's not showing up. I have a masterpage located at ~/MasterPages/MasterPage.master that holds the favicon. My markup is as follows:
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
<link rel="icon" href="/favicon.ico" type="image/x-icon"/>
The favicon is located in the project root. The dimensions are 16x16 and it's 32-bit depth. I've cleared my browser's cache, rebooted and nothing is working. Any suggestions as to what I should do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
尝试放置
~
并将link
元素设置为runat=server
这也需要在
< 中完成/code> 页面部分。
Try placing a
~
and set thelink
elements torunat=server
This also needs to be done in the
<head>
section of the page.尝试放弃该类型,清除浏览器缓存并手动转到该图标地址并向其添加一些参数。那应该解决它。也许你可以告诉我你的网站地址,然后我会看看,如果它出现在这里。
Try to leave the type away, clear the browser cache and go to the favicon address manually and add some parameters to it. That should fix it. Maybe you could tell me your website address, then I will look, if it shows up here.
右键单击解决方案并转到“属性”。在“申请”下>资源将默认图标更改为您选择的图标。
Right click on the solution and go to Properties. Under Application > Resources change the default icon to your chosen one.
加载小提琴手
http://www.fiddler2.com/fiddler2/
并查找来自浏览器的请求 - 这将显示它是否成功、缓存问题等。
Load up fiddler
http://www.fiddler2.com/fiddler2/
and look for the request from the browser for it - that will show you if its successful, a cache issue, etc.
在 .NET Core 应用程序(MVC 模板)中,尝试将 favicon.ico 文件移动到 lib 文件夹而不是 wwwroot 文件夹。
In a .NET Core app (MVC template) try moving the favicon.ico file to the lib folder instead of the wwwroot folder.
我最终通过将 favicon.ico 重命名为 myicon.ico 解决了这个问题,并在头部引用它
I finally solved this problem by renaming favicon.ico to myicon.ico, and reference it in the head
<link rel="icon" href="~/myicon.ico" type="image/x-icon" />
我在ASP.NET中使用了这个方法:
I used this method in ASP.NET: