<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb" -->

---
title: Custom media types for ASP.NET Web API versioning
description: A walkthrough of implementing API versioning in ASP.NET Web API using custom media types instead of URL-based versioning, inspired by GitHub's API versioning...
canonical: https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Custom media types for ASP.NET Web API versioning | daily.dev
og:description: A walkthrough of implementing API versioning in ASP.NET Web API using custom media types instead of URL-based versioning, inspired by GitHub's API versioning...
og:url: https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb
og:image: https://api.daily.dev/og/posts/vjTFd2gvb.png
og:image:alt: Custom media types for ASP.NET Web API versioning
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom media types for ASP.NET Web API versioning

**[Maarten Balliauw](https://daily.dev/sources/maartenballiauw)** · 6 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of implementing API versioning in ASP.NET Web API using custom media types instead of URL-based versioning, inspired by GitHub's API versioning approach (e.g., application/vnd.github.v3+json). The post builds on a CodePlex sample for namespace-based controller routing, extending it with a custom IHttpControllerSelector that inspects the Accept header to select the correct controller namespace. Includes full code for the selector, wiring it into HttpConfiguration, a regex-based GitHub-style media type parser, and configuring JSON/XML formatters to recognize custom media types. An edit links to a GitHub project with additional versioning implementations.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.maartenballiauw.be/posts/2013-03-08-custom-media-types-for-aspnet-web-api-versioning>

## Questions this post answers

### How do I version an ASP.NET Web API using the Accept header instead of the URL?

Implement a custom IHttpControllerSelector that inspects the Accept header's media type or version parameter and maps it to a namespace-qualified controller lookup key, such as 'v1.Products'. Register it with config.Services.Replace(typeof(IHttpControllerSelector), ...), passing a lambda that extracts the version from either a 'version' parameter (e.g., application/json;version=1.0) or a GitHub-style media type (e.g., application/vnd.api.v1+json) and returns the matching namespace.

_daily.dev surfaces practical ASP.NET Web API patterns like this for developers wiring up versioned REST endpoints._

### How does GitHub's API versioning scheme work with custom media types?

GitHub versions its API (since v3) by varying the Accept header's media type rather than changing endpoint URLs, so /users/repos stays constant while the response format is controlled by headers like application/vnd.github.v3+json or application/vnd.github.v3+xml. New versions, such as application/vnd.github.v4, can be introduced without altering any URL, keeping resource addresses stable across versions.

_Developers comparing URL versus header-based API versioning strategies can track real-world examples on daily.dev._

## Similar posts on daily.dev

- [Combining API versioning with OpenAPI in .NET 10 applications](https://daily.dev/posts/combining-api-versioning-with-openapi-in-net-10-applications-gmga4jjr0) · ASP.NET Blog · 25 upvotes · 0 comments
- [ASP.NET Core Controllers: A Practical Guide to Building REST Endpoints](https://daily.dev/posts/asp-net-core-controllers-a-practical-guide-to-building-rest-endpoints-qbrdx5rqi) · We Are .NET · 0 upvotes · 0 comments
- [API Versioning in ASP.NET Core - The .NET 10 Guide](https://daily.dev/posts/api-versioning-in-asp-net-core---the-net-10-guide-tuk1mrkia) · Code with Mukesh · 9 upvotes · 0 comments
- [How to Upgrade ASP.NET MVC to .NET Step by Step](https://daily.dev/posts/how-to-upgrade-asp-net-mvc-to-net-step-by-step-i3p1uesfs) · C\# Corner · 2 upvotes · 0 comments
- [Spring Framework 7 API Versioning Explained](https://daily.dev/posts/spring-framework-7-api-versioning-explained-gau0lxh9y) · Foojay.io · 12 upvotes · 0 comments

---

Tags: [#c#](https://daily.dev/tags/c#), [#rest-api](https://daily.dev/tags/rest-api)

[View this post on daily.dev](https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Custom media types for ASP.NET Web API versioning","url":"https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb"},"datePublished":"2026-10-04T13:04:51.665Z","dateModified":"2026-10-04T13:08:06.506Z","description":"A walkthrough of implementing API versioning in ASP.NET Web API using custom media types instead of URL-based versioning, inspired by GitHub's API versioning...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cc63f6da01071bf02ed581d41312a14a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cc63f6da01071bf02ed581d41312a14a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Maarten Balliauw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Maarten Balliauw","logo":"https://media.daily.dev/image/upload/s--rOTg3VYO--/f_auto,q_auto/v1791119043/logos/maartenballiauw?_a=BAMAMicg0","url":"https://daily.dev/sources/maartenballiauw"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c#,rest-api","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Maarten Balliauw","item":"https://daily.dev/sources/maartenballiauw"},{"@type":"ListItem","position":3,"name":"Custom media types for ASP.NET Web API versioning"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/custom-media-types-for-asp-net-web-api-versioning-vjtfd2gvb#faq","mainEntity":[{"@type":"Question","name":"How do I version an ASP.NET Web API using the Accept header instead of the URL?","acceptedAnswer":{"@type":"Answer","text":"Implement a custom IHttpControllerSelector that inspects the Accept header's media type or version parameter and maps it to a namespace-qualified controller lookup key, such as 'v1.Products'. Register it with config.Services.Replace(typeof(IHttpControllerSelector), ...), passing a lambda that extracts the version from either a 'version' parameter (e.g., application/json;version=1.0) or a GitHub-style media type (e.g., application/vnd.api.v1+json) and returns the matching namespace. daily.dev surfaces practical ASP.NET Web API patterns like this for developers wiring up versioned REST endpoints."}},{"@type":"Question","name":"How does GitHub's API versioning scheme work with custom media types?","acceptedAnswer":{"@type":"Answer","text":"GitHub versions its API (since v3) by varying the Accept header's media type rather than changing endpoint URLs, so /users/repos stays constant while the response format is controlled by headers like application/vnd.github.v3+json or application/vnd.github.v3+xml. New versions, such as application/vnd.github.v4, can be introduced without altering any URL, keeping resource addresses stable across versions. Developers comparing URL versus header-based API versioning strategies can track real-world examples on daily.dev."}}]}
```

