How to add favicon.ico in ASP.NET site

你说的曾经没有我的故事 提交于 2019-12-02 18:50:06
Owais Qureshi
/favicon.ico

might do the trick
I have tried this on my sample website

<link rel="shortcut icon" type="image/x-icon" href="~/ows.ico" />

Try this one in your site put the link in MasterPage,It works :)

<link rel="shortcut icon" type="image/x-icon" href="~/favicon.ico" />


I have tested in ,
FireFox.


Chrome.


Opera.

Some troubleshoots:
1. Check if your favicon is accessible (correct url) ,goto view source and click on the favicon link
2. Full refresh your browser by Ctrl+F5 every time you make changes.
3. Try searching from SO you may find your related problem here.


Some Links to help you out:
Serving favicon.ico in ASP.NET MVC
Favicon Not Showing
Why is favicon not visible

Domo

resolve the url like this href="<%=ResolveUrl("~/favicon.ico")%>"

I have the same issue. My url is as below

http://somesite/someapplication

Below doesnot work

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

I got it to work like below

<link rel="shortcut icon" type="image/x-icon" href="/someapplication/favicon.ico" />

    <link rel="shortcut icon" type="image/x-icon" href="~/favicon.ico" />

This worked for me. If anyone is troubleshooting while reading this - I found issues when my favicon.ico was not nested in the root folder. I had mine in the Resources folder and was struggling at that point.

Thanks!

Simply:

/favicon.ico

The leading slash is important.

Check out this great tutorial on favicons and browser support.

@Scripts.Render("~/favicon.ico"); Please try above code at the bottom of your Layout file in MVC

    <link rel="shortcut icon" href="@Url.Content("~/images/")favicon.ico" type="image/x-icon"/ >

This works for me in MVC4 application favicon image is placed in the images folder and it will traverse from root directory to images and find favicon.ico bingo!

for me, it didn't work without specifying the MIME in web.config, under <system.webServer><staticContent>

<mimeMap fileExtension=".ico" mimeType="image/ico" />
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!