When I run my app in visual studio 2017 using IIS Express it is able to locate the favicon.ico in the wwwroot folder. When it's deployed to IIS on a server then it can't find it.
I think it has to do with the url...
in development the url is https://localhost:44359 The favicon show up and if I manually type https://localhost:44359/favicon.ico then it returns it.
in production the url is https://localhost/reporting The favicon doesn't show up and seems to be looking for it at https://localhost/favicon.ico (which returns a 404). If I change that to http://localhost/reporting/favicon.ico then it returns the icon.
Can someone please suggest why it's not automatically looking for the icon under /reporting/ ??
I have a couple of routing issues as well, but other than that the app seems to work fine. I think the routing issues may have the same cause as the favicon.
Browsers only check example.com/favicon.ico
- they don't check in subfolders.
If you're putting it somewhere non-standard (you are!), you'll need to point browsers to it. In the <head>
of your pages:
<link rel="shortcut icon" href="/reporting/favicon.ico">
There is an issue with finding static resources for applications that are in subfolders of a website. However, in Razor pages, in the <head>
you can use:
<link rel="shortcut icon" href='@Url.Content("~/favicon.ico")'>
where the ~ refers to your application's wwwroot folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With