1

I am trying to load a trackCues.vtt file that is stored in my solution and I am trying to load this resource in my view in the following manner:

<video style="margin-top:30px;margin-bottom:30px" width="800" height="600" controls>
    <source src='@Url.Content("~/Content/AudioAssets/speechSample.mp4")' type="video/mp4">
    <track src='@Url.Content("~/Content/AudioAssets/trackCues.vtt")' kind="metadata" default>
</video>

however when the page loads I receive the following error:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:33862/Content/AudioAssets\trackCues.vtt

I'm not sure why this is failing as the path look correct (I must be wrong about that though)

Note: I load my video out of the same directory and using the same syntax so I'm not sure why the .vtt file won't load

GregH
  • 5,125
  • 8
  • 55
  • 109

1 Answers1

2

Specify Mime-Type in ApplicationHost.config

Add the following configuration to the staticContent section of ApplicationHost.config

<mimeMap fileExtension=".vtt" mimeType="text/vtt" />

The configuration file be found at:

%HOMEPATH%\Documents\IISExpress\config\ApplicationHost.config

Specify Mime-Type in Web.config (worked for OP)

This configuration allows the the project to be deployed without having to change any server settings.

<system.webServer>
    <staticContent>
        <remove fileExtension=".vtt" />
        <mimeMap fileExtension=".vtt" mimeType="text/vtt" />
    </staticContent>
</system.webServer>
dana
  • 17,267
  • 6
  • 64
  • 88
  • Replace the `` placeholder with the username that you used to login with. A shortcut is to look here `%HOMEPATH%\Documents\IISExpress\config` – dana Jan 20 '17 at 20:38
  • I found it- had my documents folder stored on a different machine on the network. Still not working after adding the mimeMap though. same error – GregH Jan 20 '17 at 20:40
  • Maybe try restarting IIS Express? – dana Jan 20 '17 at 20:42
  • based on your answer, I found a solution here: http://stackoverflow.com/questions/9021946/add-mime-mapping-in-web-config-for-iis-express you put me on the right track so I'd love to accept your answer- just please update to also include this method (which I believe to be better anyway since it is portable between machines) – GregH Jan 20 '17 at 20:44
  • Done :) I agree that specifying this in `Web.config` might save some headache down the line. One of the benefits of specifying these things on a server-wide configuration though is that all sites will be updated. In any case, glad this worked for you. – dana Jan 20 '17 at 20:54
  • good point. didnt think of the advantage of specifying through the server – GregH Jan 20 '17 at 21:13