Question

I have a Webform that contains the following HTML:

<body>
    <form id="form1" runat="server">
    <div>
        <video style="width: 100%;" controls autoplay>
            <source src="<%= this.MP4 %>" type="video/mp4">
            <source src="<%= this.OGV %>" type="video/ogg">
            <source src="<%= this.WEBM %>" type="video/webm">
        Your browser does not support the video tag.
        </video>
    </div>
    </form>
</body>

This page is opened in a fancybox window, and the according video file is given through a url parameter (video.aspx?video=filename) with which the path to the file is built in the code behind.

When I try it locally with Visual Studio 2012, everything works fine. Also if I call the file through the URL directly like so for instance: http://localhost:52916/_video/filename.webm it works as well.

Here is the code:

protected void Page_PreRender(object sender, EventArgs e)
{
    MP4 += Request.QueryString["video"] + ".mp4";
    OGV += Request.QueryString["video"] + ".ogv";
    WEBM += Request.QueryString["video"] + ".webm";
}

But on the live server the videos can't be found (404), also if called directly and when I check the Chrome Console I can see that all the GET requests for the video files get cancelled.

And it doesn't make any difference whether the page is opened in the fancybox window or if I open it directly, it still doesn't work. I also tried it with the paths to the files already filled in instead of doing it prgrammatically.

I found several people that seemed to have the same kind of problem, but none of their solutions worked.

Was it helpful?

Solution

If it is working locally, but not live, the problem is likely that the live web server is not configured to serve up those file types. Try adding this in your web.config under the system.webServer entry:

<staticContent>
    <mimeMap fileExtension=".ogg" mimeType="application/ogg" />
    <mimeMap fileExtension=".oga" mimeType="audio/ogg" />
    <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
    <mimeMap fileExtension=".webm" mimeType="video/webm" />
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>

In some versions of IIS, unknown file extensions (like ogg, webm) will cause a 404, which is why you have to define the mime type.

OTHER TIPS

You should encode your video file name (actual video URL) when setting. If you are setting the file name through code behind on directly then Server.URLEncode should work. If you are sending your filename to a js function which in turns does the rest then use AntiXss librarie's JavaScriptEncode function.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top