{"record":{"id":"09e0b868889800f0","repo":"aspnetboilerplate/aspnetboilerplate","slug":"requested-mime-type-is-not-registered","errorCode":null,"errorMessage":"Requested mime type is not registered: ","messagePattern":"Requested mime type is not registered: ","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Abp/MimeTypes/MimeTypeMap.cs","lineNumber":853,"sourceCode":"        /// <param name=\"throwErrorIfNotFound\">if set to <c>true</c>, throws error if extension's not found.</param>\n        /// <returns>The extension.</returns>\n        /// <exception cref=\"ArgumentNullException\" />\n        /// <exception cref=\"ArgumentException\" />\n        public virtual string GetExtension(string mimeType, bool throwErrorIfNotFound = true)\n        {\n            if (string.IsNullOrWhiteSpace(mimeType))\n            {\n                throw new ArgumentNullException(nameof(mimeType));\n            }\n\n            if (TryGetExtension(mimeType, out string extension))\n            {\n                return extension;\n            }\n\n            if (throwErrorIfNotFound)\n            {\n                throw new ArgumentException(\"Requested mime type is not registered: \" + mimeType);\n            }\n\n            return string.Empty;\n        }\n\n        /// <summary>\n        /// Adds MIME type to map\n        /// </summary>\n        /// <param name=\"mimeType\">Type of the MIME.</param>\n        /// <param name=\"extension\">Type of the extension</param>\n        /// <exception cref=\"ArgumentNullException\" />\n        /// <exception cref=\"ArgumentException\" />\n        public void AddMimeType(string mimeType, string extension)\n        {\n            if (string.IsNullOrWhiteSpace(mimeType))\n            {\n                throw new ArgumentNullException(nameof(mimeType));\n            }","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2323c13a152aa0ebfb37af3830f687d7f5b53795/src/Abp/MimeTypes/MimeTypeMap.cs#L835-L871","documentation":"MimeTypeMap.GetExtension looks up the file extension registered for a MIME type. When the MIME type has no registered extension and throwErrorIfNotFound is true, it throws ArgumentException; otherwise it returns string.Empty.","triggerScenarios":"Calling MimeTypeMap.GetExtension(mimeType) (or an overload with throwErrorIfNotFound: true) with a MIME type absent from the mapping dictionary, e.g. GetExtension(\"application/vnd.unknown+json\").","commonSituations":"Vendor-specific or rarely used MIME types with no extension mapping; MIME types coming from HTTP Content-Type headers with parameters or slight typos; custom MIME types used before calling AddMimeType.","solutions":["Verify the MIME type string is correct and registered; normalize (lowercase, strip parameters like '; charset=utf-8').","Register a mapping first via MimeTypeMap.AddMimeType(mimeType, extension).","Call with throwErrorIfNotFound: false and fall back to a default extension (e.g. \".bin\")."],"exampleFix":"// before\nvar ext = MimeTypeMap.GetExtension(contentType);\n// after\nvar ext = MimeTypeMap.GetExtension(contentType, throwErrorIfNotFound: false);\nif (string.IsNullOrEmpty(ext)) ext = \".bin\";","handlingStrategy":"fallback","validationCode":"bool registered = !string.IsNullOrEmpty(MimeTypeMap.GetExtension(mimeType, throwErrorIfNotFound: false));","typeGuard":null,"tryCatchPattern":"string ext;\ntry { ext = MimeTypeMap.GetExtension(mimeType); }\ncatch (ArgumentException) { ext = \".bin\"; }","preventionTips":["Use throwErrorIfNotFound: false when unknown MIME types are expected.","Normalize MIME types (lowercase, remove parameters) before lookup.","Register needed vendor MIME types via AddMimeType at startup."],"tags":["csharp","mime","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"2323c13a152aa0ebfb37af3830f687d7f5b53795","analyzedAt":"2026-09-08T08:00:50.638Z","contentChangedAt":"2026-09-08T08:00:50.638Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}