How to setup Handler Mapping for IIS 10 to serve mkv files?

I have Virtual Directory set up successfully. It serves most common file types, but not .mkv. I've tried adding new Handler Mappings via IIS Manager, but to no avail. I'm choosing the "Add Managed Handler" and reading has pointed me to try things such as "video/mkv" (also application/octet-stream) in the "Type" textbox, but I just get an http error saying:

Could not load type 'video/mkv'.

I note the drop-down appears to be libraries (e.g. System.Web.DefaultHttpHandler).

How do I set up these handler mappings?


Solution 1:

Rather than a handler mapping you need to set up a new MIME type, because the file is just a static resource.

in IIS Manager select the web site and then MIME types.

Add MIME type

you could also use PowerShell:

 Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/staticContent" -name "." -value @{fileExtension='.mkv';mimeType='video/x-matroska'}

This does the same for the default web site, but requires the WebAdministration PowerShell module to be installed.