/managedcode-mimetypes
Use ManagedCode.MimeTypes when a .NET application needs consistent MIME type detection, extension mapping, and content-type decisions for uploads, downloads, or HTTP responses. USE FOR: integrating ManagedCode.MimeTypes into upload or download flows; mapping file extensions to
$ npx -y skills add managedcode/dotnet-skills --skill managedcode-mimetypes --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/managedcode-mimetypes
Context preview
The summary Claude sees to decide when to auto-load this skill.
Use ManagedCode.MimeTypes when a .NET application needs consistent MIME type detection, extension mapping, and content-type decisions for uploads, downloads, or HTTP responses. USE FOR: integrating ManagedCode.MimeTypes into upload or download flows; mapping file extensions to
SKILL.md
managedcode-mimetypes.SKILL.mdname: managedcode-mimetypes
description: "Use ManagedCode.MimeTypes when a .NET application needs consistent MIME type detection, extension mapping, and content-type decisions for uploads, downloads, or HTTP responses. USE FOR: integrating ManagedCode.MimeTypes into upload or download flows; mapping file extensions to content types in APIs or background processing; reviewing content-type. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made."
compatibility: "Requires a .NET application that integrates ManagedCode.MimeTypes or evaluates MIME type mapping behavior."
ManagedCode.MimeTypes
Trigger On
- integrating `ManagedCode.MimeTypes` into upload or download flows
- mapping file extensions to content types in APIs or background processing
- reviewing content-type handling for files, blobs, or attachments
- documenting a reusable MIME-type decision point in a .NET application
Install
dotnet add package ManagedCode.MimeTypes --version 10.0.10
Use `PackageReference` when the repository centralizes dependency versions:
<PackageReference Include="ManagedCode.MimeTypes" Version="10.0.10" />
The current package targets .NET 8, 9, and 10. Keep the version in the repository's existing central package-management file when one is present.
Workflow
1. Identify where the application needs stable MIME-type decisions:
- upload validation
- download response headers
- storage metadata
- attachment processing
2. Centralize content-type mapping instead of scattering ad-hoc string tables across the codebase. 3. Use one library boundary for extension and MIME lookups. 4. Validate the extensions and media types that matter to the product. 5. Document any product-specific overrides separately from the library defaults.
Read MIME Metadata
Map file names, URLs, and compound extensions through the generated catalog:
using ManagedCode.MimeTypes;
var reportType = MimeHelper.GetMimeType("report.pdf");
var archiveType = MimeHelper.GetMimeType("archive.tar.gz");
var imageType = MimeHelper.GetMimeType("https://cdn.example.test/avatar.png?v=2");
var jpegExtensions = MimeHelper.GetExtensions("image/jpeg");Use registry metadata when the application needs provenance or registration details:
if (MimeHelper.TryGetMimeTypeInfoByExtension("report.pdf", out var info))
{
Console.WriteLine($"{info.Mime} registered={info.IsIanaRegistered}");
}Write Application Mappings
Register product-specific mappings at startup and remove them only when the owning application lifecycle requires it:
MimeHelper.RegisterMimeType("acme", "application/x-acme");
var customType = MimeHelper.GetMimeType("invoice.acme");
MimeHelper.UnregisterMimeType("acme");Runtime registrations affect extension and reverse lookup, but do not synthesize full IANA registry metadata.
Validate Upload Content
Treat the extension and declared content type as claims. Inspect the signature before accepting security-sensitive uploads:
using var stream = upload.OpenReadStream();
if (!MimeHelper.MatchesMimeTypeByContent(stream, upload.ContentType) ||
!MimeHelper.MatchesExtensionByContent(upload.FileName, stream))
{
throw new InvalidOperationException("Upload content does not match its declared type.");
}`GetMimeTypeByContent` and the `Matches*ByContent` helpers inspect known prefixes and restore the position of seekable streams. They are not full document parsers, malware scanners, or proof that the remainder of a file is valid.
Settings and Tradeoffs
- Unknown extensions resolve to `MimeHelper.DefaultMimeType`, initially `application/octet-stream`; use `SetDefaultMimeType` only when the whole application owns a different fallback contract.
- Prefer `MimeHelper.Instance` through `IMimeHelper` when dependency injection and test substitution are useful; use static calls for small, deterministic mapping boundaries.
- The `10.0.10` release refreshes the generated MIME database. It adds mappings such as `aaud`, `aimg`, `avid`, `coswid`, `mmdb`, `multitrack`, and `zdoc`; changes mappings including `dpkg`, `vsc`, and `wv`; and removes stale entries such as `ac2`, `cbor`, `docjson`, and `sarif-external-properties`. Re-run product-specific mapping tests because preferred mappings can change without an API change.
- Never trust MIME classification alone for authorization, file execution, archive extraction, or active-content rendering.
flowchart LR
A["File name or extension"] --> B["ManagedCode.MimeTypes lookup"]
B --> C["Resolved MIME type"]
C --> D["Upload validation, storage metadata, or HTTP response"]
Deliver
- guidance on where MIME lookup belongs in application code
- recommendations for centralized content-type decisions
- validation expectations for real file types used by the product
Validate
- MIME mapping is not duplicated across multiple services or controllers
- important file types are verified explicitly
- response or storage code uses the resolved type consistently
- `dotnet restore` resolves `ManagedCode.MimeTypes` `10.0.10` or the repository-approved newer version
- focused tests cover known extensions, unknown fallbacks, reverse lookup, upload signature mismatches, and any runtime registrations
- `dotnet test` passes for the projects that own upload, download, or storage behavior
Read more
name: managedcode-mimetypes description: "Use ManagedCode.MimeTypes when a .NET application needs consistent MIME type detection, extension mapping, and content-type decisions for uploads, downloads, or HTTP responses. USE FOR: integrating ManagedCode.MimeTypes into upload or download flows; mapping file extensions to content types in APIs or background processing; reviewing content-type. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made." compatibility: "Requires a .NET application that integrates ManagedCode.MimeTypes or evaluates MIME type mapping behavior."
ManagedCode.MimeTypes
Trigger On
- integrating `ManagedCode.MimeTypes` into upload or download flows
- mapping file extensions to content types in APIs or background processing
- reviewing content-type handling for files, blobs, or attachments
- documenting a reusable MIME-type decision point in a .NET application
Install
dotnet add package ManagedCode.MimeTypes --version 10.0.10
Use `PackageReference` when the repository centralizes dependency versions:
<PackageReference Include="ManagedCode.MimeTypes" Version="10.0.10" />
The current package targets .NET 8, 9, and 10. Keep the version in the repository's existing central package-management file when one is present.
Workflow
1. Identify where the application needs stable MIME-type decisions:
- upload validation
- download response headers
- storage metadata
- attachment processing
2. Centralize content-type mapping instead of scattering ad-hoc string tables across the codebase. 3. Use one library boundary for extension and MIME lookups. 4. Validate the extensions and media types that matter to the product. 5. Document any product-specific overrides separately from the library defaults.
Read MIME Metadata
Map file names, URLs, and compound extensions through the generated catalog:
using ManagedCode.MimeTypes;
var reportType = MimeHelper.GetMimeType("report.pdf");
var archiveType = MimeHelper.GetMimeType("archive.tar.gz");
var imageType = MimeHelper.GetMimeType("https://cdn.example.test/avatar.png?v=2");
var jpegExtensions = MimeHelper.GetExtensions("image/jpeg");Use registry metadata when the application needs provenance or registration details:
if (MimeHelper.TryGetMimeTypeInfoByExtension("report.pdf", out var info))
{
Console.WriteLine($"{info.Mime} registered={info.IsIanaRegistered}");
}Write Application Mappings
Register product-specific mappings at startup and remove them only when the owning application lifecycle requires it:
MimeHelper.RegisterMimeType("acme", "application/x-acme");
var customType = MimeHelper.GetMimeType("invoice.acme");
MimeHelper.UnregisterMimeType("acme");Runtime registrations affect extension and reverse lookup, but do not synthesize full IANA registry metadata.
Validate Upload Content
Treat the extension and declared content type as claims. Inspect the signature before accepting security-sensitive uploads:
using var stream = upload.OpenReadStream();
if (!MimeHelper.MatchesMimeTypeByContent(stream, upload.ContentType) ||
!MimeHelper.MatchesExtensionByContent(upload.FileName, stream))
{
throw new InvalidOperationException("Upload content does not match its declared type.");
}`GetMimeTypeByContent` and the `Matches*ByContent` helpers inspect known prefixes and restore the position of seekable streams. They are not full document parsers, malware scanners, or proof that the remainder of a file is valid.
Settings and Tradeoffs
- Unknown extensions resolve to `MimeHelper.DefaultMimeType`, initially `application/octet-stream`; use `SetDefaultMimeType` only when the whole application owns a different fallback contract.
- Prefer `MimeHelper.Instance` through `IMimeHelper` when dependency injection and test substitution are useful; use static calls for small, deterministic mapping boundaries.
- The `10.0.10` release refreshes the generated MIME database. It adds mappings such as `aaud`, `aimg`, `avid`, `coswid`, `mmdb`, `multitrack`, and `zdoc`; changes mappings including `dpkg`, `vsc`, and `wv`; and removes stale entries such as `ac2`, `cbor`, `docjson`, and `sarif-external-properties`. Re-run product-specific mapping tests because preferred mappings can change without an API change.
- Never trust MIME classification alone for authorization, file execution, archive extraction, or active-content rendering.
flowchart LR A["File name or extension"] --> B["ManagedCode.MimeTypes lookup"] B --> C["Resolved MIME type"] C --> D["Upload validation, storage metadata, or HTTP response"]
Deliver
- guidance on where MIME lookup belongs in application code
- recommendations for centralized content-type decisions
- validation expectations for real file types used by the product
Validate
- MIME mapping is not duplicated across multiple services or controllers
- important file types are verified explicitly
- response or storage code uses the resolved type consistently
- `dotnet restore` resolves `ManagedCode.MimeTypes` `10.0.10` or the repository-approved newer version
- focused tests cover known extensions, unknown fallbacks, reverse lookup, upload signature mismatches, and any runtime registrations
- `dotnet test` passes for the projects that own upload, download, or storage behavior
Stop explaining .NET to your AI. Start building. We've all been there: asking Claude to use Entity Framework, only to get EF6 patterns in a .NET 8 project. Explaining to Copilot that Blazor Server and Blazor WebAssembly aren't the same thing.
Repo: managedcode/dotnet-skills
Other skills on dotnet-skills.
- /aspnet-core
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET. USE FOR: working on ASP.NET Core apps, services, or middleware; changing auth, routing, configuration,
Open skill - /aspire
Build, upgrade, and operate Aspire 13.4.x C# or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, MCP, and deployment patterns for distributed apps. USE FOR: Aspire.AppHost.Sdk, Aspire.Hosting.*,
Open skill - /azure-functions
Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR: working on Azure Functions in .NET; migrating from the in-process model to the isolated worker model; adding Durable
Open skill - /blazor
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices. USE FOR: building interactive web UIs with C# instead of JavaScript; choosing between Server, WebAssembly, or
Open skill - /entity-framework6
Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is not the right next step. USE FOR: EF6 codebases; runtime versus ORM migration decisions; EDMX, code-first, ObjectContext, and legacy data-access
Open skill - /entity-framework-core
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and
Open skill

