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. How to force a file download?

How to force a file download?

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharpasp-netcom
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.
  • F Offline
    F Offline
    FruitBatInShades
    wrote on last edited by
    #1

    I am in need of some help, there doesn't seem to be much advice covering what i need to do :( My site uses authentication for different subscriptions. I need to allow users to download files based on their role. I don't want to link to a URL becuase that url can be passed around. How can I force a file to be downloaded but not reveal it's location on the server? Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair)
    My First ASP.Net site is now up :) RedRavenRPG

    J 1 Reply Last reply
    0
    • F FruitBatInShades

      I am in need of some help, there doesn't seem to be much advice covering what i need to do :( My site uses authentication for different subscriptions. I need to allow users to download files based on their role. I don't want to link to a URL becuase that url can be passed around. How can I force a file to be downloaded but not reveal it's location on the server? Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair)
      My First ASP.Net site is now up :) RedRavenRPG

      J Offline
      J Offline
      Juno EasyDotNet com
      wrote on last edited by
      #2

      Hi, try this in code behide: response.redirect("yourfile.zip") Juno MCSD.NET, MCDBA, MCSE ---------------------------------------------------------- Support Team of EasyDotNet, INC. http://www.EasyDotNet.com DataForm.NET - The most powerful data entry web server control for ASP.NET

      C 1 Reply Last reply
      0
      • J Juno EasyDotNet com

        Hi, try this in code behide: response.redirect("yourfile.zip") Juno MCSD.NET, MCDBA, MCSE ---------------------------------------------------------- Support Team of EasyDotNet, INC. http://www.EasyDotNet.com DataForm.NET - The most powerful data entry web server control for ASP.NET

        C Offline
        C Offline
        ChrisAdams
        wrote on last edited by
        #3

        Or you could use as asp.net page to stream the content out. You would have to load the file into a stream, then write the bytes out to the response using Request.BinaryWrite() This way you could do extra checking etc before actually streaming the file, like ensuring the person has come from your website first etc.

        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