>Yesterday, I spent most of my afternoon looking through the Moodle code to try to work out why whenever a file was downloaded in Moodle, the Moodle login page was shown within the document when changing from protected view. The behaviour is consistent across Windows 8 and Office 2010 and 2013 suites from what I can tell.

As you can imagine, this is rather frustrating for all users who need to download any files from Moodle courses. The only workaround that I could find was to get users to save the document, rather than open it. It turns out that this behaviour relates to the use of Internet Explorer and an Office suite of applications. It seems that the Office application¬†tries to download the file, hence why the login screen is displayed. There were various solutions touted on the Moodle forums but there wasn’t anything concrete. Some suggested adding prohibited verbs in IIS for the values of ‘OPTIONS’ and ‘PROPFIND’, but in my experience yesterday this made no difference whatsoever. This behaviour does not happen whenever you attempt to download a file from a folder oddly enough and only seems to happen from a course home page.

The only way that I could force users to download the file was to change pluginfile.php in the root of the Moodle install on line 35 to read the following:

$forcedownload = optional_param(‘forcedownload’, 1, PARAM_BOOL);

This seems to work and fixes the problem completely. Time will tell whether or not this breaks something else but for now I’m running with it. I’ll keep an eye on this to see if there’s a permanent fix that can be achieved from the IIS side of things, however it seems that there are other people out there with the same problem. York St John University¬†are also apparently having the same issue and they’re running Apache.