Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Olly Berry 47 posts 68 karma points
    Nov 25, 2009 @ 15:42
    Olly Berry
    0

    Force "Save As" for .doc/.docx/.pdf files?

    Hello,

     

    I am working on an Umbraco 4 site which has lots of documents available to download in .doc, .docx and .pdf format.

    The files are all stored in the Umbraco Media node and linked on the content pages.

    The links all work in the respect that they point to the right files, and if I right click/save as or save link as, I can download them all just fine.

    My problem is that with a left click, the save as dialog does not appear, Umbraco attempts (and fails) to open them in the browser and I'm getting a 404 error.

    How can I force the save as dialog?

    Many thanks,

    Olly

  • Petr Snobelt 923 posts 1535 karma points
    Nov 25, 2009 @ 16:08
    Petr Snobelt
    0

    You can create handler, which send content-disposition header, which should force browser to display download dialog.

  • Olly Berry 47 posts 68 karma points
    Nov 25, 2009 @ 16:11
    Olly Berry
    0

    Thanks Petr, do you have any idea how to implement this in Umbraco?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 25, 2009 @ 16:40
    Dirk De Grave
    0

    Olly,

    Must implement a class that inherits from IHttpHandler and implement the ProcessRequest() method which should take care of setting the required header info as Petr suggests. Once ready, compile project and throw assembly in /bin folder (or add .cs file to App_code folder) and register the handler in your web.config.

     

    Hope this helps.

    Regards,

    /Dirk

  • Olly Berry 47 posts 68 karma points
    Nov 25, 2009 @ 17:05
    Olly Berry
    0

    Sorry Dirk, you've lost me - I know how to create a handler (.ashx) to do this, but this would mean each link would have to point to the handler - I need users to be able to add links to file in the media node using tinyMCE, and for these links to force the save as dialog.

    Would your method allow this? If so, I'm unsure how to process.

    Many thanks for your help so far.

     

    Olly

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Nov 25, 2009 @ 23:57
    Morten Bock
    1

    I'm not sure it is actually Umbraco that is doing this. It could just as well be your IIS that is not sending a suitable content header. How are you hosting your site? Own/shared server? IIS 6/7? Classic mode/ integrated pipeline?

    I thing there are many ways to handle this depending on your setup. Also without creating a "proxy" handler.

  • dandrayne 1138 posts 2262 karma points
    Nov 26, 2009 @ 02:37
    dandrayne
    2

    You'll probably need to add the MIME types to iis - http://support.microsoft.com/kb/326965

    Dan

  • Olly Berry 47 posts 68 karma points
    Nov 26, 2009 @ 11:38
    Olly Berry
    0

    Thanks Dan, didn't even consider this as I incorrectly thought the site was hosted on the same IIS as another which was working fine. All good now.

Please Sign in or register to post replies

Write your reply to:

Draft