nopSolutions/nopCommerce · error · InvalidOperationException
File is not supported.
Error message
File is not supported.
What it means
Thrown in the favicon/app-icon upload flow when the uploaded file's extension is neither .ico nor .zip, hitting the default case of the switch and throwing InvalidOperationException('File is not supported.'). It is a hard format gate before any extraction work.
Source
Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/SettingController.cs:1865
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
await _customerActivityService.InsertActivityAsync("UploadIcons", string.Format(await _localizationService.GetResourceAsync("ActivityLog.UploadNewIcons"), storeScope));
_notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Configuration.FaviconAndAppIcons.Uploaded"));
}
catch (Exception exc)
{
await _notificationService.ErrorNotificationAsync(exc);
}
View on GitHub (pinned to 64bdf2ff08)
Solutions
- Upload either a single .ico or a prepared .zip of icons; convert other formats first.
- Add an `accept=".ico,.zip"` attribute on the file input to prevent bad selections.
- Pre-validate the extension server-side and return a friendly notification instead of throwing.
- Document the accepted formats next to the uploader.
Example fix
// before
default:
throw new InvalidOperationException("File is not supported.");
// after
default:
_notificationService.ErrorNotification("Only .ico and .zip files are supported.");
return View(model);
// plus client-side:
// <input type="file" accept=".ico,.zip" /> Defensive patterns
Strategy: validation
Validate before calling
var ext = _fileProvider.GetFileExtension(fileName).ToLowerInvariant();
if (ext != ".ico" && ext != ".zip")
return ErrorResult("Only .ico and .zip are supported."); Type guard
static bool IsSupportedIconFile(string fileName)
{
var ext = Path.GetExtension(fileName)?.ToLowerInvariant();
return ext == ".ico" || ext == ".zip";
} Try / catch
catch (InvalidOperationException ex) when (ex.Message == "File is not supported.")
{ _notificationService.ErrorNotification("Use .ico or .zip."); return View(model); } Prevention
- Add accept=".ico,.zip" on the file input.
- Validate the extension server-side before the switch.
- Document accepted formats beside the uploader.
When it happens
Trigger: Uploading .png, .jpg, .gif, .svg, or any non-.ico/.zip file to the favicon/app-icons uploader; user mis-selecting an image instead of the prepared ico/zip.
Common situations: Operators unfamiliar with the required formats attempting to upload a raw PNG/SVG; automated tooling posting the wrong content type; frontend not restricting accepted extensions.
Related errors
- Admin.Configuration.Settings.GeneralCommon.FaviconAndAppIcon
- Admin.Configuration.Settings.GeneralCommon.EncryptionKey.Too
- Admin.Configuration.Settings.GeneralCommon.EncryptionKey.The
- Email is not valid.
- {titleRequiredLocale} (localized, formatted with languageNam
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/6b12dbd7b599e7cc.
Report an issue: GitHub.