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. ASP.NET
  4. Downloading documents from an ASP.NET 2.0 page

Downloading documents from an ASP.NET 2.0 page

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netquestion
3 Posts 2 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.
  • S Offline
    S Offline
    seee sharp
    wrote on last edited by
    #1

    Hello, I have following code for providing download of file. byte[] bytes = this.ContentController.GetFileContents(_filePath); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=Document.pdf" ); Response.AddHeader("Content-Length", bytes.Length.ToString()); Response.ContentType = "*/*"; Response.BinaryWrite(bytes); This provides a messagebox on browser with Open/Save/Cancel button. When I click on save, this saves the document on the disk, and I can open that. But when I click on Open, this does not open the document. A prompt from PDF reader says, file not found. How can I getrid of this problem. Any help is appreciated. Thanks in advance.:)

    - ashish

    P 1 Reply Last reply
    0
    • S seee sharp

      Hello, I have following code for providing download of file. byte[] bytes = this.ContentController.GetFileContents(_filePath); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=Document.pdf" ); Response.AddHeader("Content-Length", bytes.Length.ToString()); Response.ContentType = "*/*"; Response.BinaryWrite(bytes); This provides a messagebox on browser with Open/Save/Cancel button. When I click on save, this saves the document on the disk, and I can open that. But when I click on Open, this does not open the document. A prompt from PDF reader says, file not found. How can I getrid of this problem. Any help is appreciated. Thanks in advance.:)

      - ashish

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      You could try putting a Response.Flush() at the end of your code there.

      S 1 Reply Last reply
      0
      • P Paddy Boyd

        You could try putting a Response.Flush() at the end of your code there.

        S Offline
        S Offline
        seee sharp
        wrote on last edited by
        #3

        Even after adding Response.Flush() I am getting the same problem. Additionally, I am haiving this eventhandller written in User control which is placed on a view (Web form). I am also using Masterpage and UIP Application Blocks.

        - ashish

        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