Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've built a Javascript web application which is served from Sharepoint (ie. there is no Sharepoint code at all operating on the web app, it's just some HTML/JS being served from a Sharepoint 2010 Document Library)

I'm displaying HTML5 video and sourcing a file from within the same Document Library, this works absolutely fine on Google Chrome, but if I try with Firefox (or with IE9) then every file I source gets denied twice with an HTTP 401 error before it gets returned with HTTP 200.

The upshot of this is that if I have a very simple HTML file (see below) and run it locally then the video plays fine in all browsers, if I upload the HTML and the video to my company's sharepoint server (into a document library) then it won't load in IE or Firefox - but works fine in Chrome!

<html>
<body>
    <video>
        <source src="localvideo.webm" type="video/webm">
    </video>
</body>
</html>

If I change the source element to reference a video file on a different server then it, again, works fine so this must be a problem with the way Sharepoint is serving files. Does anyone have any advice on how to work around this problem? Either in Sharepoint or in JS? There is no chance of me being able to edit anything above a site owner's privileges.

share|improve this question
    
It's worth mentioning that all other files served in this manner (images, JS files etc) are loaded correctly in all browsers. –  JP. Oct 28 '11 at 10:44

2 Answers 2

Two HTTP 401 responses is normal when using NTLM authn, that's the way HTTP works.

First it tries an anonymous request which generates the first 401 request. The reponse includes a header that says "try with NTLM".

Then the NTLM procedure (which is a challenge/response method) requires one 401 and finally a 200. If you want more details here's a good link: http://davenport.sourceforge.net/ntlm.html#ntlmHttpAuthentication

If you switch to Kerberos for instance, you will get one 401 (the anonymous request) and then a 200 (when the kerberos token is sent).

(I know this doesn't answer your question completley, but that's why you get two 401's.)

share|improve this answer
    
I've never heard anyone explain it so concisely. Thanks, Wictor! –  Marc D Anderson Oct 28 '11 at 11:31
2  
Thanks! The two 401's are one reason why Kerberos can improve performance of your SharePoint. Just take a look at the payload size of the 401's served from IIS - and then two of them for every single HTTP request :-) –  Wictor Wilen MCA MCM MVP Oct 28 '11 at 11:53
    
Awesome explanation Wictor, thanks! –  webdes03 Oct 28 '11 at 13:32
    
Just repeating, but this is an awesome question and answer! Thanks! –  Anita Boerboom Oct 29 '11 at 7:54
    
@Wictor:Nice explanation. However, I wonder how Kerberos is faster than NTLM when Kerberos is more complicated process (than NTLM). –  Amit Kumawat Nov 19 '11 at 18:03

Wictor's answer is an excellent one, but for me the root cause of this issue was IIS' mime-type settings.

IE and Firefox will completely adhere to the mime-type sent by the server (the default one being application/octet-stream for IIS) but also will not play a video if the mime-type isn't correct - video/webm, video/ogg or video/mp4. By contrast Google Chrome will guess the mime-type based on the contents of the file (a dangerous habit already steeped in debate) - hence the difference between the browsers.

The solution to this problem is to add these mime-types to IIS' system settings and reboot (details can be found here). I hope this helps someone else - it took me forever to stumble across this!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.