---
title: "Mime Type Helper in .NET 11"
description: "New helper will be available with .NET 11: `MediaTypeMap.GetMediaType` and `MediaTypeMap.GetExtension` which makes the web-development a bit easier!"
updated: 2025-12-02
tags: [".NET 11"]
canonical: "https://steven-giesel.com/blogPost/8f41d316-f6ac-4712-bf11-ea36b7c2f2e6/mime-type-helper-in-net-11"
---

# Mime Type Helper in .NET 11

New helper will be available with .NET 11: `MediaTypeMap.GetMediaType` and `MediaTypeMap.GetExtension` which makes the web-development a bit easier!

## `MediaTypeMap.GetMediaType`

The basic idea is that you get the [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types) from a given file **or** extension:
```csharp
using System.Net.Mime;

_ = MediaTypeMap.GetMediaType("myfile.css"); // text/css
_ = MediaTypeMap.GetMediaType("resource.json"); // application/json
_ = MediaTypeMap.GetMediaType("rEsOuRCe.JsOn"); // application/json
_ = MediaTypeMap.GetMediaType("steven.giesel"); // null - as giesel is unfortunately not a wellknown extension

// It also works JUST with extensions or the whole path
_ = MediaTypeMap.GetMediaType("/home/user/myfile.css"); // text/css
_ = MediaTypeMap.GetMediaType("css"); // text/css
```

We can also "reverse-lookup" via:

## `MediaTypeMap.GetExtension`

```csharp
using System.Net.Mime;

_ = MediaTypeMap.GetExtension("application/pdf"); // ".pdf"
_ = MediaTypeMap.GetExtension("image/jpeg"); // ".jpg"

// Returns null for unknown ones
_ = MediaTypeMap.GetExtension("madeup/mimetype"); // null
_ = MediaTypeMap.GetExtension("/some/path/basic.css"); // null
```

It is also with a leading ".".
## Resources:
 * Issue on GitHub: https://github.com/dotnet/runtime/issues/121017
 * Merged PR (if you want to have the full list): https://github.com/dotnet/runtime/pull/121776