Home » none » Secret to Unique FavIcon.ico files in DotNetNuke

Secret to Unique FavIcon.ico files in DotNetNuke

Well, it was a secret to me until yesterday anyhow.

If you are running a DotNetNuke installation with multiple portals, you may have noticed that even if you replace the FavIcon.ico file in the root of the application, you get the same FavIcon.ico file displaying for all of your portals.  And, even if you have just one portal and upgrade the portal and forget to not copy the FavIcon.ico file up, of course you’ll have to recopy the one you want back up.

So, while I was trying to track down another problem yesterday, I was in the Default.aspx.vb file of the 4.8 release of DotNetNuke when I notice these lines:

Private Sub ManageFavicon()
    Dim strFavicon As String = _
DataCache.GetCache("FAVICON" & _
PortalSettings.PortalId.ToString), String) If strFavicon = "" Then If File.Exists(PortalSettings.HomeDirectoryMapPath & _
"favicon.ico") Then strFavicon = PortalSettings.HomeDirectory & "favicon.ico" If Not Common.Globals.PerformanceSetting = _
Common.Globals.PerformanceSettings.NoCaching Then DataCache.SetCache("FAVICON" & _
PortalSettings.PortalId.ToString, strFavicon) End If End If End If If strFavicon <> "" Then Dim objLink As New HtmlLink() objLink.Attributes("rel") = "SHORTCUT ICON" objLink.Attributes("href") = strFavicon Page.Header.Controls.Add(objLink) End If End Sub


Check it out!  It’s looking for a favicon.ico file in the portal’s directory (ie, portal/0, portal/1, etc) and if it finds it it is inserting

<link rel=”SHORTCUT ICON” href=”path to portal favicon.ico here” />

into the HEAD of the page.

This means that every portal can have a unique icon associated with it.  Cool!

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • DotNetNuke – Modules – Portal Specific ModulesDotNetNuke – Modules – Portal Specific Modules Many of you won't care too much about creating Portal Specific Modules because you'll be creating modules for an environment that only has one portal. However, if you are creating a […]
  • DotNetNuke Modules – PortalModuleBaseDotNetNuke Modules – PortalModuleBase We've been through most of the basics now with respect to creating the View module of the DotNetNuke module set.  We will be moving on to the Settings module next.  But before we do, we […]
  • DotNetNuke – Data Access Layer AlternativeDotNetNuke – Data Access Layer Alternative Now that I've explained the standard way of creating a Data Access Layer (DAL) for DotNetNuke, we can address the alternative method of providing this same functionality.You see, the only […]
  • DotNetNuke CSS in your Module SettingsDotNetNuke CSS in your Module Settings I have a friend that is working at a local college who called recently because he was having some trouble with his CSS using the Module Settings feature where you can add additional code […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.