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. General Programming
  3. C#
  4. How can we restrict a user from changing the download path url's fine name.

How can we restrict a user from changing the download path url's fine name.

Scheduled Pinned Locked Moved C#
comhelp
5 Posts 5 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.
  • U Offline
    U Offline
    User 8224730
    wrote on last edited by
    #1

    Ex: If I send user the download url like http://www.mysite.com/downloads/file1.pdf but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf. How can we restrict users from doing this. I really appreciate for you help.... Thanks Nani

    A S P M 4 Replies Last reply
    0
    • U User 8224730

      Ex: If I send user the download url like http://www.mysite.com/downloads/file1.pdf but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf. How can we restrict users from doing this. I really appreciate for you help.... Thanks Nani

      A Offline
      A Offline
      Andre Kraak
      wrote on last edited by
      #2

      How about using randomly generated file names so that the user has no way of replacing the file name?

      0100000101101110011001000111001011101001

      1 Reply Last reply
      0
      • U User 8224730

        Ex: If I send user the download url like http://www.mysite.com/downloads/file1.pdf but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf. How can we restrict users from doing this. I really appreciate for you help.... Thanks Nani

        S Offline
        S Offline
        ScottM1
        wrote on last edited by
        #3

        You would have to keep the files in a different location and then use a Web Handler file (ASHX) to read the file bytes and Write them to the Response.

        1 Reply Last reply
        0
        • U User 8224730

          Ex: If I send user the download url like http://www.mysite.com/downloads/file1.pdf but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf. How can we restrict users from doing this. I really appreciate for you help.... Thanks Nani

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Nani - you actually need to invert your thinking on this. Should you be restricting the user from doing this? If the user has the permissions to download the file then why should you restrict it? If, however, you change the problem around to "should I allow a user to be able to download a file that they don't have permissions to?" then you get a totally different question, but a one that makes a lot of sense. You can use the security aspects of ASP.NET - and combine this with ashx handlers to parse the request that's coming in - and control the users access to the files. BTW - this should have been asked in the ASP.NET forum, not this one.

          Forgive your enemies - it messes with their heads

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          1 Reply Last reply
          0
          • U User 8224730

            Ex: If I send user the download url like http://www.mysite.com/downloads/file1.pdf but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf. How can we restrict users from doing this. I really appreciate for you help.... Thanks Nani

            M Offline
            M Offline
            Matt Meyer
            wrote on last edited by
            #5

            You accomplish this by keeping your assets in a non-accessible location (eg, somewhere in App_Data) and using an HttpHandler to serve the files out after verifying permissions.

            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