nopSolutions/nopCommerce · error · Exception
Only icons are supported (*.ico)
Error message
Only icons are supported (*.ico)
What it means
Thrown by UploadService.UploadFaviconAsync when the uploaded favicon's extension is not '.ico'. It inspects _fileProvider.GetFileExtension(favicon.FileName) and throws a plain Exception unless it case-insensitively equals '.ico'. Nothing is written to disk before the throw.
Source
Thrown at src/Libraries/Nop.Services/Plugins/UploadService.cs:403
{
//delete the zip file and leave only unpacked files in the folder
if (!string.IsNullOrEmpty(zipFilePath))
_fileProvider.DeleteFile(zipFilePath);
}
}
/// <summary>
/// Upload single favicon
/// </summary>
/// <param name="favicon">Favicon</param>
/// <returns>A task that represents the asynchronous operation</returns>
public virtual async Task UploadFaviconAsync(IFormFile favicon)
{
ArgumentNullException.ThrowIfNull(favicon);
//only icons are supported
if (!_fileProvider.GetFileExtension(favicon.FileName)?.Equals(".ico", StringComparison.InvariantCultureIgnoreCase) ?? true)
throw new Exception("Only icons are supported (*.ico)");
//check if there is a folder for favicon (favicon folder is in wwwroot/icons and is called icons_{storeId})
var storeFaviconPath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.FaviconAndAppIconsPath, await _storeContext.GetActiveStoreScopeConfigurationAsync()));
CreateDirectory(storeFaviconPath);
var faviconPath = _fileProvider.Combine(storeFaviconPath, favicon.FileName);
await using var fileStream = new FileStream(faviconPath, FileMode.Create);
await favicon.CopyToAsync(fileStream);
}
/// <summary>
/// Upload locale pattern for current culture
/// </summary>
/// <param name="cultureInfo">CultureInfo</param>
/// <returns>A task that represents the asynchronous operation</returns>
public virtual Task UploadLocalePatternAsync(CultureInfo cultureInfo = null)
{View on GitHub (pinned to 64bdf2ff08)
Solutions
- Convert the image to a genuine .ico file with an icon editor (e.g. ICOConvert, GIMP, ImageMagick 'convert favicon.png favicon.ico') and upload that.
- Confirm the file actually ends in '.ico' in the OS before uploading.
- If you need PNG favicons, that path is not this API — add a <link rel="icon"> in your theme instead.
Example fix
// before: favicon.png uploaded // after: convert then upload // convert -resize 32x32 favicon.png favicon.ico (ImageMagick)
Defensive patterns
Strategy: validation
Validate before calling
var ext = Path.GetExtension(favicon?.FileName);
if (!string.Equals(ext, ".ico", StringComparison.OrdinalIgnoreCase))
return BadRequest("A .ico favicon is required."); Type guard
static bool IsValidFavicon(IFormFile f) =>
f is not null &&
string.Equals(Path.GetExtension(f.FileName), ".ico", StringComparison.OrdinalIgnoreCase); Try / catch
try { await _uploadService.UploadFaviconAsync(file); }
catch (Exception ex) when (ex.Message.Contains("*.ico"))
{ ModelState.AddModelError("favicon", "Upload an .ico file."); } Prevention
- Convert images to .ico before uploading.
- Add client-side accept='.ico' on the file input.
- Provide a converter in admin tooling.
When it happens
Trigger: Uploading a favicon in a modern format (.png, .svg, .webp, .gif) through the admin favicon upload control. Also triggers on a null/extensionless FileName because GetFileExtension returns null and the null-coalesce yields true.
Common situations: Designers deliver a .png/.svg favicon; converting .png to .ico with a non-favicon tool; uploading an animated .gif favicon; mobile upload renaming the file.
Related errors
- Only zip archives are supported (*.zip)
- Cannot decode picture binary (file name: {fileName})
- Archive '{NopCommonDefaults.LocalePatternArchiveName}' to re
- Discount could not be loaded
- Request data is missing
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/0cf7f0032a3f95bb.
Report an issue: GitHub.