Forum Discussion

Gerardo_Garcia_'s avatar
Gerardo_Garcia_
Icon for Nimbostratus rankNimbostratus
May 21, 2008

Content Disposition

We have a web application that includes Microsoft Office documents links.

 

When you click on the document using IE you will see an embedded document in your browser.

 

 

We are getting all kind of errors

 

The vendor does offer that functionality to download instead of a regular link.

 

 

Is there a way to modify the content disposition from whatever it is to download for the Microsoft Office Documents?

 

 

 

3 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    I can't recall off the top of my head whether it's the content-disposition header or a different one you'd want to change to stop it from automatically viewing the content in the browser, but that shouldn't be too hard to track down. If it is the content-disposition header, you'd probably want to change it to attachment instead of inline.

     

     

    This can be done easily with the HTTP::header Replace command.

     

     

    Colin
  • I'm not sure what your exact criteria is for rewriting the header. Here is an example that would rewrite every Content-Disposition header if it's present in the response:

      
      when HTTP_RESPONSE {  
          Check if the response has a Content-Disposition header  
         if {[HTTP::header exists Content-Disposition]}{  
        
             Replace the existing Content-Disposition header  
             with one that prompts the user to download the content  
            HTTP::header replace Content-Disposition "attachment; filename="  
         }  
      }  
      

    I didn't test to see if you have to specify a filename. I doubt you do though. You might also want to limit when the header replacement is done by characteristics of the request or response. If you post an example of the response headers for a response you want to rewrite we might be able to give you more detailed suggestions.

    Aaron