nopSolutions/nopCommerce · error · Exception

Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcon

Error message

Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcons.MissingFile

What it means

Thrown during favicon/app-icon upload (ChangeEncryptionKey-adjacent settings flow) when a .zip archive is uploaded but the expected head-code file (NopCommonDefaults.HeadCodeFileName) is not produced inside the extraction path. The localized 'MissingFile' message is formatted with the expected filename. It signals a malformed or incomplete icons archive.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/SettingController.cs:1857

            //load settings for a chosen store scope
            var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();
            var commonSettings = await _settingService.LoadSettingAsync<CommonSettings>(storeScope);

            switch (_fileProvider.GetFileExtension(iconsFile.FileName))
            {
                case ".ico":
                    await _uploadService.UploadFaviconAsync(iconsFile);
                    commonSettings.FaviconAndAppIconsHeadCode = string.Format(NopCommonDefaults.SingleFaviconHeadLink, storeScope, iconsFile.FileName);

                    break;

                case ".zip":
                    await _uploadService.UploadIconsArchiveAsync(iconsFile);

                    var headCodePath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.FaviconAndAppIconsPath, storeScope), NopCommonDefaults.HeadCodeFileName);
                    if (!_fileProvider.FileExists(headCodePath))
                        throw new Exception(string.Format(await _localizationService.GetResourceAsync("Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcons.MissingFile"), NopCommonDefaults.HeadCodeFileName));

                    using (var sr = new StreamReader(headCodePath))
                        commonSettings.FaviconAndAppIconsHeadCode = await sr.ReadToEndAsync();

                    break;

                default:
                    throw new InvalidOperationException("File is not supported.");
            }

            await _settingService.SaveSettingOverridablePerStoreAsync(commonSettings, x => x.FaviconAndAppIconsHeadCode, true, storeScope);

            //delete old favicon icon if exist
            var oldFaviconIconPath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.OldFaviconIconName, storeScope));
            if (_fileProvider.FileExists(oldFaviconIconPath))
                _fileProvider.DeleteFile(oldFaviconIconPath);

            //activity log

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Regenerate the icons archive with a tool that emits the head-code file at the expected path.
  2. Inspect the zip contents and ensure NopCommonDefaults.HeadCodeFileName exists at the root of the extraction dir.
  3. Try the .ico path instead if you only need a single favicon.
  4. Confirm write permissions on the favicon path so extraction succeeds.

Example fix

// before
if (!_fileProvider.FileExists(headCodePath))
    throw new Exception(string.Format(await _localizationService.GetResourceAsync("Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcons.MissingFile"), NopCommonDefaults.HeadCodeFileName));

// after
if (!_fileProvider.FileExists(headCodePath))
{
    _notificationService.ErrorNotification($"Icons archive is missing the '{NopCommonDefaults.HeadCodeFileName}' file.");
    return View(model);
}
Defensive patterns

Strategy: validation

Validate before calling

var headCodePath = _fileProvider.GetAbsolutePath(...);
if (!_fileProvider.FileExists(headCodePath))
    return ErrorResult($"Icons archive is missing '{NopCommonDefaults.HeadCodeFileName}'.");

Type guard

static bool ArchiveHasHeadCode(string extractedDir, string fileName)
    => File.Exists(Path.Combine(extractedDir, fileName));

Try / catch

catch (Exception ex) when (ex.Message.Contains("MissingFile"))
{ _notificationService.ErrorNotification(ex.Message); return View(model); }

Prevention

When it happens

Trigger: Uploading a .zip that does not contain the head-code file (e.g. html) at the expected location; zip with wrong folder structure; extraction silently failing; zip produced by an incompatible icon generator.

Common situations: Using a third-party favicon generator whose zip layout differs from nopCommerce's expected FaviconAndAppIconsPath; corrupted zip; partial upload; wrong default file name configured.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/d06bb96548a342a5. Report an issue: GitHub.