I recently encountered an issue while working on a site with the standard Kentico web part icons disappearing. After talking with Dominik Pinter
, I found the issue was something kind of interesting so I wanted to pass the info along to everyone.
First, a little background. I have a site I currently have deployed into Windows Azure using Kentico’s recommended configuration. All files are being stored in Windows Azure storage, and more importantly, all web part icons show up. The site is configured to store all images on the file system (Site Manager / Settings / System / Files) and everything works great.
When I pulled the site local to my machine and fired it up for some changes, I found that all of the web part icons were mysteriously absent.
Web part icons missing
After scratching my head for a few minutes I started my hunt for the cause. All the web part functionality worked fine, as did everything in the site. I checked documents types and they appeared fine, as well. I created a new web part that showed the icon correctly. Even updating an existing web part resulted in the icon showing. The issue was only with the existing web parts and their icons.
After determining that most things works correctly, I thought maybe the issue was with the actual rendering of the image. Because these are “system-type” files they are rendered a little differently than most things in that they do not have a direct URL in the system. All icon files utilize the CMSPages/GetMetaFile.aspx file to retrieve the image and then deliver it in the request. I set several break points in this code and tried many, many times to get an image to display without any luck. I was starting to think that the issue might be in my actual machine until I talked with Dominik.
I reviewed the symptoms and code with Dominik who had a great idea to try. By default, an Azure project utilizes storage and the file system quite differently from a “standard” deployment. The icon files for web parts are generated dynamically behind the scenes and stored in the CMSFiles folder for future use. In a standard deployment is a local folder within the site. In an Azure project, this is included with the Azure storage files.
The root cause of the issue was that my project was configured to use Azure Storage for the files, however, I was running it locally. While this is totally fine to do and our preferred method when developing locally, behind the scenes the site will still be looking for certain files on the file system which had previously been stored in Azure storage.
The solution was actually quite simple. Connect to Azure storage and copy the cmsroot/cmsfiles from the Windows Azure Storage Account to the local machine and BAM! All my icons show up.
Windows Azure Storage Files
Web part icons shown
What this shows is how important it is to understand what’s happening behind the scenes with your project. Because Kentico runs natively in Azure and leverages several APIs, it will handle and process files considerably different than other deployments. Leveraging this knowledge and a strong understanding of the platform will save you tons of time in your development and help you build a better app.
I hope this info helps you in your development and avoid problems in the future!