Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add favicon.ico in ASP.NET site

The solution structure of my application is:

enter image description here

Now I am in Login.aspx and I am willing to add favicon.ico, placed in the root, in that page.

What I am doing is:

<link id="Link1" runat="server" rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />   <link id="Link2" runat="server" rel="icon" href="../favicon.ico" type="image/ico" />  

Also I have tried:

<link id="Link1" runat="server" rel="shortcut icon" href="favicon.ico" type="image/x-icon" />   <link id="Link2" runat="server" rel="icon" href="favicon.ico" type="image/ico" />  

But these aren't working.

I have cleared the browser cache but no luck.

What will be the path to the favicon.ico from:

  • Login.aspx
  • Site.master

Thank you.


The login page's URL: http://localhost:2873/Pages/Login.aspx and the favicon.ico's URL: http://localhost:2873/favicon.ico.

I am unable to see the favicon.ico enter image description here after changing my code as:

<link id="Link1" rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />   <link id="Link2" rel="icon" href="/favicon.ico" type="image/ico" /> 
like image 687
Tapas Bose Avatar asked Apr 01 '12 10:04

Tapas Bose


People also ask

What is favicon ICO in asp net?

A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. Adding a Favicon is a nice way to enhance your website and give it a finished look.

How do I add a favicon to ico?

To add a favicon to your website, either save your favicon image to the root directory of your webserver, or create a folder in the root directory called images, and save your favicon image in this folder. A common name for a favicon image is "favicon.ico".

How do I change the favicon in .NET core?

tag in your html or cshtml. For me, adding favicon. ico to wwwroot folder and pressing CTRL + F5 on my browser cleared the cache and made the new icon show up.


2 Answers

/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.
enter image description here
Chrome.
enter image description here
Opera.
enter image description here

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

like image 141
Owais Qureshi Avatar answered Oct 09 '22 10:10

Owais Qureshi


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

like image 31
Domo Avatar answered Oct 09 '22 09:10

Domo