Bug 19952 - Missing mime types in XSP
Summary: Missing mime types in XSP
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Marek Habersack
Depends on:
Reported: 2014-05-21 06:18 UTC by helmut.ziegler
Modified: 2014-05-23 11:45 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description helmut.ziegler 2014-05-21 06:18:30 UTC
We run a local xsp webserver that hosts an asp.net mvc application. The application should deliver mp4 files.

With Firefox this seems to work fine. When I enter the mp4 url (e. g. localhost:8080/test.mp4) the mp4 video is displayed in the video player of the browser.

When I do this with IE9/IE10 a download dialog appears. The issue seems to be that XSP does not add the correct mime type to the mp4 file (video/mp4) but application/octet-stream.

Is there a way to configure/ change this?
Comment 1 Miguel de Icaza [MSFT] 2014-05-23 10:09:43 UTC
XSP is not a production web server, it is just a testing server, so many features do not exist.

I have CCed Marek that can comment on this
Comment 2 Miguel de Icaza [MSFT] 2014-05-23 10:10:08 UTC
[10:09:38]  <grendel>	 miguel: mime types are in system.web and one can extend the system with web.config
Comment 3 helmut.ziegler 2014-05-23 11:45:08 UTC
I've mailed with Marek. He made two suggestions:

1. Define an HttpHandler for the file extension in my application.

2. Add the missing MimeTypes to https://github.com/mono/mono/blob/master/mcs/class/System.Web/System.Web/MimeTypes.cs

Concerning suggestion 1 I have the following solution (for those who have the same requirement)

      <add verb="*" path="*.mp4" type="MyApp.Helpers.MimeTypeHandler" />

namespace MyApp.Helpers
    public class MimeTypeHandler : IHttpHandler
        public bool IsReusable
                return false;

        public void ProcessRequest(HttpContext context)
            string absolutePath = context.Server.MapPath("~" + context.Request.Url.PathAndQuery);
            var length = new System.IO.FileInfo(absolutePath).Length;
            context.Response.CacheControl = "Public";
            context.Response.AddHeader("Content-Length", length.ToString());
            context.Response.ContentType = "video/mp4";

Concerning suggestion 2: 

Richard Meyer (https://github.com/meyerrj) has already changed this in January(https://github.com/mono/mono/commit/4ee22819a50c4e7503dea54705eb11f93c84c26e)
Unfortunately it is not yet part of the latest Mono release.
I'll try to compile the current source code...

Thanks for the feedback to you both!