views:

1108

answers:

3

I'm trying to stream QuickTime video to an iPhone from an ASP.NET web application using an HttpHandler. When hosting the web application from IIS 5.1 (Windows XP), the video player opens and then displays the error 'The server is not correctly configured'. However, when using IIS 7.5 (Windows 7), the video plays fine.

The production environment is running IIS 6.0 and has the same problem, where attempting to play videos on the iPhone via Mobile Safari displays the error above.

I've checked the Http Headers and they appear to be practically the same between the two servers (apart from a few, such as the Server header, which will obviously be different), except they appear in different order, though I doubt that this is causing the problem.

According to this thread on Google Groups, adding the 'Accept-Ranges: bytes' header can help, though this made no difference for us. I've also added the ETag header, without any luck.

The code actually responsible for sending the file looks something like this:

Context.Response.Buffer = true;
Context.Response.ContentType = "video/x-m4v";

Context.Response.AppendHeader("Content-Disposition", "filename=\"Video.m4v\"");
Context.Response.AppendHeader("Content-Length", "23456789");

Context.Response.AppendHeader("Accept-Ranges", "bytes");
Context.Response.AppendHeader("ETag", GetETag(path));

Context.Response.TransmitFile(path);

The code above which transmits files appears to be functioning correctly and video files play back correctly in all desktop browsers and when hosting from IIS 7.5 on Windows 7. The problem is only apparent when attempting to play video files on the iPhone using Mobile Safari using the above code with the ASP.NET web application being hosted on IIS 5.1 or IIS 6.0.

Has anyone else experienced anything like this and got any ideas on what I can do to get this working?

A: 

Use something like Fiddler to expose the exact HTTP response coming from the servers. Fudge the client's User-Agent string to match the iPhone browser (or just use Safari?) and compare the output from IIS 5.1 and 7.5. Obviously the response streams are not identical or it would be working on both.

You could also use NetMon, which is a great tool... and would allow you to test with the iPhone itself.

Sorry I don't have a specific answer for you, but I think you're going to have to get your hands dirty with this one.

Bryan
Thanks for the tips. The video actually plays back fine in Safari on Windows, and in Firefox too when using the iPhone user agent string, so I don't think it's something with this. The issue looks like it's more something to do with how IIS5/6 are transmitting the files as opposed to IIS7, which doesn't allow the iPhone to play it. Haven't used network monitoring tools much before, but will check out NetMon/Wireshark and see if they can help.
Mun
+1  A: 

Why do you set Response.Buffer to true?

You cannot simply add the "Accept-Ranges" header unless you also ensure that the server supports HTTP Range requests. If the client player demands support for Range requests and the server refuses to handle them, it seems logical that the request would be rejected.

You could try using Fiddler as a reverse-proxy and see if the IPhone makes a Range request. http://www.fiddler2.com/Fiddler/Help/ReverseProxy.asp

EricLaw -MSFT-
+1  A: 

After some searching, I came across the article Range-Specific Requests in ASP.NET which describes the exact problem I was having. Implementing the RangeRequestHandlerBase class from this site (with some minor modifications to fit within our existing project structure) seems to have solved the problem, and video playback now operates correctly from IIS5/6.

@Eric - I've upvoted your answer as your comment was a nudge in the right direction. Simply adding the 'Accept-Ranges' header was not sufficient (despite working in IIS7), and the http handler needed to be modified to handle range requests and ensure that the correct data is being sent.

Mun