I am using the code given in this link to watermark my documents.

Here the author has used IHttpHandler to watermark document whenever a user clicks on a pdf document.

Whenever I click on a document link in the document library the document gets opened inside the browser with the watermark and stuff, instead of showing the default save or cancel dialog box. I don't want the document to get displayed inside the browser and then save it from there. I want to have the default save dialog box that usually appears when you click on document link. How can I do that?

1 Answer 1


Try adding:

context.Response.AddHeader("content-disposition", "attachment;filename=" + file.Name);
  • Do I have to add this in feature event receiver or in the class where I have implemented IHttpHandler? Sorry for asking such a naive question. I am pretty new to sharepoint
    – A Beginner
    Commented Apr 27, 2015 at 12:54
  • It should be part of ProcessRequest in PDFWatermarkHttpHandler when setting context.Response.ContentType Commented Apr 27, 2015 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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