{"record":{"id":"0cf7f0032a3f95bb","repo":"nopSolutions/nopCommerce","slug":"only-icons-are-supported-ico","errorCode":null,"errorMessage":"Only icons are supported (*.ico)","messagePattern":"Only icons are supported \\(\\*\\.ico\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Plugins/UploadService.cs","lineNumber":403,"sourceCode":"        {\n            //delete the zip file and leave only unpacked files in the folder\n            if (!string.IsNullOrEmpty(zipFilePath))\n                _fileProvider.DeleteFile(zipFilePath);\n        }\n    }\n\n    /// <summary>\n    /// Upload single favicon\n    /// </summary>\n    /// <param name=\"favicon\">Favicon</param>\n    /// <returns>A task that represents the asynchronous operation</returns>\n    public virtual async Task UploadFaviconAsync(IFormFile favicon)\n    {\n        ArgumentNullException.ThrowIfNull(favicon);\n\n        //only icons are supported\n        if (!_fileProvider.GetFileExtension(favicon.FileName)?.Equals(\".ico\", StringComparison.InvariantCultureIgnoreCase) ?? true)\n            throw new Exception(\"Only icons are supported (*.ico)\");\n\n        //check if there is a folder for favicon (favicon folder is in wwwroot/icons and is called icons_{storeId})\n        var storeFaviconPath = _fileProvider.GetAbsolutePath(string.Format(NopCommonDefaults.FaviconAndAppIconsPath, await _storeContext.GetActiveStoreScopeConfigurationAsync()));\n\n        CreateDirectory(storeFaviconPath);\n\n        var faviconPath = _fileProvider.Combine(storeFaviconPath, favicon.FileName);\n        await using var fileStream = new FileStream(faviconPath, FileMode.Create);\n        await favicon.CopyToAsync(fileStream);\n    }\n\n    /// <summary>\n    /// Upload locale pattern for current culture\n    /// </summary>\n    /// <param name=\"cultureInfo\">CultureInfo</param>\n    /// <returns>A task that represents the asynchronous operation</returns>\n    public virtual Task UploadLocalePatternAsync(CultureInfo cultureInfo = null)\n    {","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Plugins/UploadService.cs#L385-L421","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: favicon.png uploaded\n// after: convert then upload\n//   convert -resize 32x32 favicon.png favicon.ico   (ImageMagick)","handlingStrategy":"validation","validationCode":"var ext = Path.GetExtension(favicon?.FileName);\nif (!string.Equals(ext, \".ico\", StringComparison.OrdinalIgnoreCase))\n    return BadRequest(\"A .ico favicon is required.\");","typeGuard":"static bool IsValidFavicon(IFormFile f) =>\n    f is not null &&\n    string.Equals(Path.GetExtension(f.FileName), \".ico\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { await _uploadService.UploadFaviconAsync(file); }\ncatch (Exception ex) when (ex.Message.Contains(\"*.ico\"))\n{ ModelState.AddModelError(\"favicon\", \"Upload an .ico file.\"); }","preventionTips":["Convert images to .ico before uploading.","Add client-side accept='.ico' on the file input.","Provide a converter in admin tooling."],"tags":["plugins","upload","file-extension","validation","favicon"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}