Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. how to restrict opening pdf file in browser

how to restrict opening pdf file in browser

Scheduled Pinned Locked Moved Web Development
htmltutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vijay_chaudhary
    wrote on last edited by
    #1

    Hi All, I have a html page in my project in which there is a link for a pdf file. When i click**(left)** on that link it opens in brwser without showing the save file dialog box as it is showing when i do right click. Thanks in advance, Vijay Kumar

    M 1 Reply Last reply
    0
    • V vijay_chaudhary

      Hi All, I have a html page in my project in which there is a link for a pdf file. When i click**(left)** on that link it opens in brwser without showing the save file dialog box as it is showing when i do right click. Thanks in advance, Vijay Kumar

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      Use the content-disposition header like this: Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition","attachment; filename=document.pdf"); Response.TransmitFile( Server.MapPath("~/files/document.pdf") ); Response.End();

      Mark's blog: developMENTALmadness.blogspot.com

      L 1 Reply Last reply
      0
      • M Mark J Miller

        Use the content-disposition header like this: Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition","attachment; filename=document.pdf"); Response.TransmitFile( Server.MapPath("~/files/document.pdf") ); Response.End();

        Mark's blog: developMENTALmadness.blogspot.com

        L Offline
        L Offline
        Lee Weston
        wrote on last edited by
        #3

        Hi I have done this and the Open and Download works fine. But if I click on the next link on my original Web part (MOSS2007) then it does not even do a Postback. If I refresh the page and click on the next link it opens correctly. Any thoughts? Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups